답안 #477016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
477016 2021-09-29T19:06:58 Z rainboy Preokret (COCI18_preokret) C
50 / 50
1 ms 292 KB
#include <stdio.h>

#define N	2879
#define M	2879
#define X	1440

int main() {
	static int xx[N], yy[M];
	int n, m, i, j, c, cnt1, cnt2;

	scanf("%d", &n);
	cnt1 = 0;
	for (i = 0; i < n; i++) {
		scanf("%d", &xx[i]);
		if (xx[i] <= X)
			cnt1++;
	}
	scanf("%d", &m);
	for (j = 0; j < m; j++) {
		scanf("%d", &yy[j]);
		if (yy[j] <= X)
			cnt1++;
	}
	i = 0, j = 0, c = 0, cnt2 = 0;
	while (i < n || j < m) {
		if (j == m || i < n && xx[i] < yy[j])
			i++;
		else
			j++;
		if (i < j && c != -1)
			c = -1, cnt2++;
		if (i > j && c != 1)
			c = 1, cnt2++;
	}
	cnt2--;
	printf("%d\n", cnt1);
	printf("%d\n", cnt2);
	return 0;
}

Compilation message

preokret.c: In function 'main':
preokret.c:26:23: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   26 |   if (j == m || i < n && xx[i] < yy[j])
      |                 ~~~~~~^~~~~~~~~~~~~~~~
preokret.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
preokret.c:14:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d", &xx[i]);
      |   ^~~~~~~~~~~~~~~~~~~
preokret.c:18:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%d", &m);
      |  ^~~~~~~~~~~~~~~
preokret.c:20:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf("%d", &yy[j]);
      |   ^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct