Submission #71249094


Source Code Expand

Copy
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int cmp(const void* x, const void* y) {
int a = *(const int*)x, b = *(const int*)y;
return (a > b) - (a < b);
}
int N;
int H[114514];
int zac;
int zal[114514];
int zaq(int q) {
int l = 0, r = zac - 1;
while (l <= r) {
int m = l + (r - l) / 2;
if (zal[m] == q) return m;
else if (zal[m] < q) l = m + 1;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int cmp(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return (a > b) - (a < b);
}

int N;
int H[114514];

int zac;
int zal[114514];

int zaq(int q) {
	int l = 0, r = zac - 1;
	while (l <= r) {
		int m = l + (r - l) / 2;
		if (zal[m] == q) return m;
		else if (zal[m] < q) l = m + 1;
		else r = m - 1;
	}
	printf("ERROR: %d not found!\n", q);
	exit(42);
}

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &H[i]) != 1) return 1;
	}
	memcpy(zal, H, sizeof(*H) * N);
	qsort(zal, N, sizeof(*zal), cmp);
	for (zac = 1, i = 1; i < N; i++) {
		if (zal[zac - 1] != zal[i]) zal[zac++] = zal[i];
	}
	for (i = 0; i < N; i++) {
		printf("%d\n", zaq(H[i]) + 1);
	}
	return 0;
}

/*

要は座標圧縮をする

*/

Submission Info

Submission Time
Task C - 陽気な妖姫
User mikecat
Language C (gcc 12.2.0)
Score 300
Code Size 901 Byte
Status AC
Exec Time 34 ms
Memory 2648 KiB

Judge Result

Set Name Sample Subtask1
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 33
Set Name Test Cases
Sample sample_1.txt, sample_2.txt, sample_3.txt
Subtask1 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 3.txt, 30.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample_1.txt, sample_2.txt, sample_3.txt
Case Name Status Exec Time Memory
1.txt AC 21 ms 2104 KiB
10.txt AC 24 ms 2304 KiB
11.txt AC 23 ms 2280 KiB
12.txt AC 1 ms 1744 KiB
13.txt AC 20 ms 2048 KiB
14.txt AC 16 ms 2112 KiB
15.txt AC 9 ms 1900 KiB
16.txt AC 8 ms 1856 KiB
17.txt AC 16 ms 1972 KiB
18.txt AC 32 ms 2564 KiB
19.txt AC 22 ms 2288 KiB
2.txt AC 10 ms 2032 KiB
20.txt AC 18 ms 2092 KiB
21.txt AC 4 ms 1676 KiB
22.txt AC 3 ms 1676 KiB
23.txt AC 27 ms 2304 KiB
24.txt AC 27 ms 2308 KiB
25.txt AC 12 ms 1952 KiB
26.txt AC 34 ms 2636 KiB
27.txt AC 12 ms 1912 KiB
28.txt AC 16 ms 2088 KiB
29.txt AC 10 ms 2028 KiB
3.txt AC 22 ms 2316 KiB
30.txt AC 1 ms 1612 KiB
4.txt AC 21 ms 2192 KiB
5.txt AC 33 ms 2648 KiB
6.txt AC 29 ms 2312 KiB
7.txt AC 15 ms 2120 KiB
8.txt AC 13 ms 1936 KiB
9.txt AC 29 ms 2308 KiB
sample_1.txt AC 0 ms 1616 KiB
sample_2.txt AC 0 ms 1592 KiB
sample_3.txt AC 0 ms 1588 KiB


2025-11-27 (Thu)
06:54:41 +09:00