From 5315e1465b2e1be00439b11a7205692d88cb5282 Mon Sep 17 00:00:00 2001 From: yenru0 Date: Mon, 8 Jul 2024 01:15:45 +0900 Subject: [PATCH] complete 19637.c --- zeta_C/completed/19637.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 zeta_C/completed/19637.c diff --git a/zeta_C/completed/19637.c b/zeta_C/completed/19637.c new file mode 100644 index 0000000..4920ab7 --- /dev/null +++ b/zeta_C/completed/19637.c @@ -0,0 +1,41 @@ +#include +#include + +typedef struct TitleCondition { + char title[12]; + int condition; +} TitleCondition; + +TitleCondition total[100000]; +int N, M; + +// tc[i-1] < x <= tc[i]일 때, tc[i] +TitleCondition *get_title(int x) { + int start = -1, end = N; + int mid; + + while (start + 1 < end) { + mid = (start + end) / 2; + if (total[mid].condition < x) { + start = mid; + } else { + end = mid; + } + } + + return total + end; +} + +int main() { + scanf("%d %d", &N, &M); + for (int i = 0; i < N; i++) { + scanf("%s %d", &total[i].title, &total[i].condition); + } + int temp; + for (int i = 0; i < M; i++) { + scanf("%d", &temp); + printf("%s\n", get_title(temp)->title); + } + + return 0; +} \ No newline at end of file