제출 #477016

#제출 시각아이디문제언어결과실행 시간메모리
477016rainboyPreokret (COCI18_preokret)C11
50 / 50
1 ms292 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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]);
      |   ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...