Submission #823872

# Submission time Handle Problem Language Result Execution time Memory
823872 2023-08-13T09:09:44 Z rainboy Triangle Collection (CCO23_day2problem3) C
10 / 25
54 ms 564 KB
#include <stdio.h>
#include <string.h>

#define N	2000

int main() {
	static int aa[N], aa_[N];
	int n, q, i, j, d;
	long long k, ans;

	scanf("%d%d", &n, &q);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	while (q--) {
		scanf("%d%d", &i, &d), i--;
		aa[i] += d;
		memcpy(aa_, aa, n * sizeof *aa);
		ans = 0;
		for (i = n - 1, j = n - 1; i >= 0; i--)
			while (aa_[i] >= 2) {
				while (j >= 0 && (j > i * 2 || aa_[j] % 2 == 0))
					j--;
				if (j >= 0)
					ans++, aa_[i] -= 2, aa_[j]--;
				else {
					k = 0;
					while (i >= 0)
						k += aa_[i], i--;
					ans += k / 3;
					break;
				}
			}
		printf("%lld\n", ans);
	}
	return 0;
}

Compilation message

Main.c: In function 'main':
Main.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d%d", &n, &q);
      |  ^~~~~~~~~~~~~~~~~~~~~
Main.c:13:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
Main.c:15:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%d%d", &i, &d), i--;
      |   ^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 17 ms 212 KB Output is correct
7 Correct 18 ms 300 KB Output is correct
8 Correct 10 ms 212 KB Output is correct
9 Correct 20 ms 300 KB Output is correct
10 Correct 19 ms 304 KB Output is correct
11 Correct 13 ms 212 KB Output is correct
12 Correct 11 ms 212 KB Output is correct
13 Correct 6 ms 212 KB Output is correct
14 Correct 4 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 17 ms 212 KB Output is correct
7 Correct 18 ms 300 KB Output is correct
8 Correct 10 ms 212 KB Output is correct
9 Correct 20 ms 300 KB Output is correct
10 Correct 19 ms 304 KB Output is correct
11 Correct 13 ms 212 KB Output is correct
12 Correct 11 ms 212 KB Output is correct
13 Correct 6 ms 212 KB Output is correct
14 Correct 4 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 10 ms 444 KB Output is correct
18 Correct 9 ms 364 KB Output is correct
19 Correct 10 ms 356 KB Output is correct
20 Correct 12 ms 340 KB Output is correct
21 Correct 22 ms 324 KB Output is correct
22 Correct 7 ms 332 KB Output is correct
23 Correct 17 ms 352 KB Output is correct
24 Correct 12 ms 360 KB Output is correct
25 Correct 10 ms 340 KB Output is correct
26 Correct 9 ms 352 KB Output is correct
27 Correct 12 ms 312 KB Output is correct
28 Correct 0 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 296 KB Output is correct
2 Correct 18 ms 212 KB Output is correct
3 Correct 54 ms 564 KB Output is correct
4 Runtime error 1 ms 340 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 19 ms 300 KB Output is correct
2 Correct 10 ms 212 KB Output is correct
3 Correct 10 ms 360 KB Output is correct
4 Correct 24 ms 296 KB Output is correct
5 Runtime error 1 ms 436 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 17 ms 212 KB Output is correct
7 Correct 18 ms 300 KB Output is correct
8 Correct 10 ms 212 KB Output is correct
9 Correct 20 ms 300 KB Output is correct
10 Correct 19 ms 304 KB Output is correct
11 Correct 13 ms 212 KB Output is correct
12 Correct 11 ms 212 KB Output is correct
13 Correct 6 ms 212 KB Output is correct
14 Correct 4 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 10 ms 444 KB Output is correct
18 Correct 9 ms 364 KB Output is correct
19 Correct 10 ms 356 KB Output is correct
20 Correct 12 ms 340 KB Output is correct
21 Correct 22 ms 324 KB Output is correct
22 Correct 7 ms 332 KB Output is correct
23 Correct 17 ms 352 KB Output is correct
24 Correct 12 ms 360 KB Output is correct
25 Correct 10 ms 340 KB Output is correct
26 Correct 9 ms 352 KB Output is correct
27 Correct 12 ms 312 KB Output is correct
28 Correct 0 ms 288 KB Output is correct
29 Correct 20 ms 296 KB Output is correct
30 Correct 18 ms 212 KB Output is correct
31 Correct 54 ms 564 KB Output is correct
32 Runtime error 1 ms 340 KB Execution killed with signal 11
33 Halted 0 ms 0 KB -