답안 #479348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
479348 2021-10-11T12:54:45 Z rainboy Jarvis (COCI19_jarvis) C
70 / 70
47 ms 2060 KB
#include <stdio.h>

#define N	100000

int max(int a, int b) { return a > b ? a : b; }

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 aa[N];
	int n, i, j, ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	for (i = 0; i < n; i++) {
		int a;

		scanf("%d", &a);
		aa[i] -= a;
	}
	sort(aa, 0, n);
	ans = 0;
	for (i = 0; i < n; i = j) {
		j = i + 1;
		while (j < n && aa[j] == aa[i])
			j++;
		ans = max(ans, j - i);
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

jarvis.c: In function 'main':
jarvis.c:36:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
jarvis.c:38:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
jarvis.c:42:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |   scanf("%d", &a);
      |   ^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB Output is correct
2 Correct 22 ms 1028 KB Output is correct
3 Correct 22 ms 1140 KB Output is correct
4 Correct 22 ms 1136 KB Output is correct
5 Correct 28 ms 2040 KB Output is correct
6 Correct 28 ms 1996 KB Output is correct
7 Correct 29 ms 1964 KB Output is correct
8 Correct 32 ms 2060 KB Output is correct
9 Correct 36 ms 2056 KB Output is correct
10 Correct 47 ms 2048 KB Output is correct