Submission #823206

# Submission time Handle Problem Language Result Execution time Memory
823206 2023-08-12T09:26:46 Z rainboy Real Mountains (CCO23_day1problem2) C
10 / 25
5000 ms 6976 KB
#include <stdio.h>

#define N	1000000
#define INF	0x3f3f3f3f
#define MD	1000003

int min(int a, int b) { return a < b ? a : b; }

int main() {
	static int aa[N];
	int n, i, l, r, a, k, bll, blr, brr, brl, ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	ans = 0;
	for (a = 1; ; a++) {
		l = 0;
		while (l < n && aa[l] <= a)
			l++;
		if (l == n)
			break;
		r = n - 1;
		while (r >= 0 && aa[r] <= a)
			r--;
		k = 0;
		for (i = l; i <= r; i++)
			if (aa[i] <= a)
				k++;
		if (k > 0) {
			ans = (ans + (long long) (a * 3 + 2) * k) % MD;
			bll = blr = INF;
			for (i = l; i <= r; i++)
				if (aa[i] > a)
					bll = min(bll, aa[i]);
				else {
					while (i <= r) {
						if (aa[i] > a)
							blr = min(blr, aa[i]);
						i++;
					}
					break;
				}
			brr = brl = INF;
			for (i = r; i >= l; i--)
				if (aa[i] > a)
					brr = min(brr, aa[i]);
				else {
					while (i >= l) {
						if (aa[i] > a)
							brl = min(brl, aa[i]);
						i--;
					}
					break;
				}
			if (k == 1)
				ans = (ans + bll + brr - (a + 1) * 2) % MD;
			else
				ans = (ans + bll + brr + min(blr, brl) - (a + 1) * 3) % MD;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

Main.c: In function 'main':
Main.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
Main.c:15:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%d", &aa[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 0 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 300 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 2 ms 312 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 3 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 0 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 300 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 2 ms 312 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 212 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 3 ms 212 KB Output is correct
19 Correct 3 ms 212 KB Output is correct
20 Correct 3 ms 212 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 2 ms 212 KB Output is correct
23 Correct 2 ms 308 KB Output is correct
24 Correct 2 ms 304 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 304 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 296 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 292 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 0 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 300 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 2 ms 312 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 212 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 3 ms 212 KB Output is correct
19 Correct 3 ms 212 KB Output is correct
20 Correct 3 ms 212 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 2 ms 212 KB Output is correct
23 Correct 2 ms 308 KB Output is correct
24 Correct 2 ms 304 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 304 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 296 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 292 KB Output is correct
35 Execution timed out 5039 ms 340 KB Time limit exceeded
36 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 0 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 300 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 2 ms 312 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 212 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 3 ms 212 KB Output is correct
19 Correct 3 ms 212 KB Output is correct
20 Correct 3 ms 212 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 2 ms 212 KB Output is correct
23 Correct 2 ms 308 KB Output is correct
24 Correct 2 ms 304 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 304 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 296 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 292 KB Output is correct
35 Execution timed out 5039 ms 340 KB Time limit exceeded
36 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 0 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 300 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 2 ms 312 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 212 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 3 ms 212 KB Output is correct
19 Correct 3 ms 212 KB Output is correct
20 Correct 3 ms 212 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 2 ms 212 KB Output is correct
23 Correct 2 ms 308 KB Output is correct
24 Correct 2 ms 304 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 304 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 296 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 292 KB Output is correct
35 Correct 650 ms 6824 KB Output is correct
36 Correct 669 ms 6648 KB Output is correct
37 Correct 667 ms 6956 KB Output is correct
38 Correct 658 ms 6976 KB Output is correct
39 Correct 661 ms 6860 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 275 ms 6124 KB Output is correct
43 Correct 283 ms 6188 KB Output is correct
44 Correct 286 ms 5820 KB Output is correct
45 Correct 291 ms 6804 KB Output is correct
46 Correct 305 ms 5168 KB Output is correct
47 Correct 272 ms 6624 KB Output is correct
48 Correct 358 ms 6860 KB Output is correct
49 Correct 364 ms 6880 KB Output is correct
50 Correct 358 ms 6692 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 0 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 300 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 2 ms 312 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 212 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 3 ms 212 KB Output is correct
19 Correct 3 ms 212 KB Output is correct
20 Correct 3 ms 212 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 2 ms 212 KB Output is correct
23 Correct 2 ms 308 KB Output is correct
24 Correct 2 ms 304 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 304 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 296 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 292 KB Output is correct
35 Execution timed out 5039 ms 340 KB Time limit exceeded
36 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 0 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 300 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 2 ms 312 KB Output is correct
11 Correct 3 ms 212 KB Output is correct
12 Correct 3 ms 212 KB Output is correct
13 Correct 3 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 3 ms 212 KB Output is correct
17 Correct 3 ms 212 KB Output is correct
18 Correct 3 ms 212 KB Output is correct
19 Correct 3 ms 212 KB Output is correct
20 Correct 3 ms 212 KB Output is correct
21 Correct 2 ms 212 KB Output is correct
22 Correct 2 ms 212 KB Output is correct
23 Correct 2 ms 308 KB Output is correct
24 Correct 2 ms 304 KB Output is correct
25 Correct 2 ms 212 KB Output is correct
26 Correct 2 ms 304 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 2 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 296 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 292 KB Output is correct
35 Execution timed out 5039 ms 340 KB Time limit exceeded
36 Halted 0 ms 0 KB -