Submission #99376

# Submission time Handle Problem Language Result Execution time Memory
99376 2019-03-03T07:54:14 Z kimcoding Preokret (COCI18_preokret) C++17
50 / 50
3 ms 384 KB
#include <cstdio>

int n, m;
int score[2900][2];

int main() {
	int n; scanf("%d", &n);
	int ans1 = 0, ans2 = 0;
	for (int i = 1,x; i <= n; i++) {
		scanf("%d", &x);
		if (x <= 1440) ans1++;
		score[x][0]++;
	}
	scanf("%d", &m);
	for (int i = 1, x; i <= m; i++) {
		scanf("%d", &x);
		if (x <= 1440) ans1++;
		score[x][1]++;
	}
	int anow = 0, bnow = 0;
	bool awin = true, bwin = true;
	for (int i = 0; i < 2900; i++) {
		if (!score[i][0] && !score[i][1]) continue;
		anow += score[i][0];
		bnow += score[i][1];
		if (anow > bnow) {
			if (!awin) ans2++;
			awin = true, bwin = false;
		}
		if (bnow > anow) {
			if (!bwin) ans2++;
			bwin = true, awin = false;
		}
	}
	printf("%d\n%d\n", ans1, ans2);
	return 0;
 }

Compilation message

preokret.cpp: In function 'int main()':
preokret.cpp:7:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n; scanf("%d", &n);
         ~~~~~^~~~~~~~~~
preokret.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
preokret.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &m);
  ~~~~~^~~~~~~~~~
preokret.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 384 KB Output is correct