Submission #795912

# Submission time Handle Problem Language Result Execution time Memory
795912 2023-07-27T21:47:51 Z rainboy 점 모으기 (KOI13_collect) C
24 / 24
26 ms 2132 KB
#include <stdio.h>

#define N	100000

unsigned int X = 12345;

int rand_() {
	return (X *= 3) >> 1;
}

void sort(int *aa, int l, int r) {
	while (l < r) {
		int i = l, j = l, k = r, a = aa[l + rand_() % (r - l)], tmp;

		while (j < k)
			if (aa[j] == a)
				j++;
			else if (aa[j] < a) {
				tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
				i++, j++;
			} else {
				k--;
				tmp = aa[j], aa[j] = aa[k], aa[k] = tmp;
			}
		sort(aa, l, i);
		l = k;
	}
}

int main() {
	static int xx[N], yy[N];
	int n, i, j, ans;

	scanf("%*d%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d%d", &xx[i], &yy[i]);
	sort(xx, 0, n), sort(yy, 0, n);
	ans = 0;
	for (i = 0, j = n - 1; i < j; i++, j--)
		ans += xx[j] - xx[i];
	for (i = 0, j = n - 1; i < j; i++, j--)
		ans += yy[j] - yy[i];
	printf("%d\n", ans);
	return 0;
}

Compilation message

ee.c: In function 'main':
ee.c:34:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |  scanf("%*d%d", &n);
      |  ^~~~~~~~~~~~~~~~~~
ee.c:36:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |   scanf("%d%d", &xx[i], &yy[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 288 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 296 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 388 KB Output is correct
2 Correct 6 ms 540 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 724 KB Output is correct
2 Correct 11 ms 920 KB Output is correct
3 Correct 8 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1108 KB Output is correct
2 Correct 14 ms 1304 KB Output is correct
3 Correct 17 ms 1488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1872 KB Output is correct
2 Correct 25 ms 1964 KB Output is correct
3 Correct 15 ms 1580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 22 ms 1744 KB Output is correct
3 Correct 26 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 2132 KB Output is correct
2 Correct 26 ms 2116 KB Output is correct
3 Correct 26 ms 2100 KB Output is correct