Submission #201231

# Submission time Handle Problem Language Result Execution time Memory
201231 2020-02-10T00:05:28 Z ainta Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
83 ms 132344 KB
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
int n;
long long X[410], Left[410][410][410], Right[410][410][410], T[410], L;
int main() {
	int i, j, k;
	scanf("%d%lld", &n, &L);
	for (i = n + 1; i <= n + n; i++) scanf("%lld", &X[i]);
	for (i = n + 1; i <= n + n; i++) scanf("%lld", &T[i]);
	for (i = 0; i < n; i++) {
		X[i] = X[n + 1 + i] - L;
		T[i] = T[n + 1 + i];
	}
	for (i = n; i >= 0; i--) {
		for (j = n - i; j <= n; j++) {
			int b = j, e = j + i;
			for (k = 0; k <= n; k++)Left[b][e][k] = Right[b][e][k] = -1e18;
			Left[b][e][0] = Right[b][e][0] = 1e18;
			for (k = 1; k <= n - i; k++) {
				long long t1 = max(min(Left[b - 1][e][k - 1], T[b - 1]), Left[b - 1][e][k]) - (X[b] - X[b - 1]);
				long long t2 = max(min(Right[b][e + 1][k - 1], T[e + 1]), Right[b][e + 1][k]) - (X[e + 1] - X[b]);
				if (max(t1, t2) >= 0)Left[b][e][k] = max(t1, t2);
				t1 = max(min(Left[b - 1][e][k - 1], T[b - 1]), Left[b - 1][e][k]) - (X[e] - X[b - 1]);
				t2 = max(min(Right[b][e + 1][k - 1], T[e + 1]), Right[b][e + 1][k]) - (X[e + 1] - X[e]);
				if (max(t1, t2) >= 0)Right[b][e][k] = max(t1, t2);
			}
		}
	}
	int res = 0;
	for (i = 1; i <= n; i++)if (Left[n][n][i] >= 0 || Right[n][n][i]>=0)res = i;
	printf("%d\n", res);
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%lld", &n, &L);
  ~~~~~^~~~~~~~~~~~~~~~~~
ho_t3.cpp:10:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i = n + 1; i <= n + n; i++) scanf("%lld", &X[i]);
                                   ~~~~~^~~~~~~~~~~~~~~
ho_t3.cpp:11:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i = n + 1; i <= n + n; i++) scanf("%lld", &T[i]);
                                   ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 760 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 892 KB Output is correct
13 Correct 5 ms 1016 KB Output is correct
14 Correct 5 ms 508 KB Output is correct
15 Correct 5 ms 632 KB Output is correct
16 Correct 5 ms 1016 KB Output is correct
17 Correct 5 ms 1020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 760 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 892 KB Output is correct
13 Correct 5 ms 1016 KB Output is correct
14 Correct 5 ms 508 KB Output is correct
15 Correct 5 ms 632 KB Output is correct
16 Correct 5 ms 1016 KB Output is correct
17 Correct 5 ms 1020 KB Output is correct
18 Correct 5 ms 1144 KB Output is correct
19 Correct 5 ms 760 KB Output is correct
20 Correct 5 ms 1016 KB Output is correct
21 Correct 5 ms 1144 KB Output is correct
22 Correct 5 ms 760 KB Output is correct
23 Correct 5 ms 1272 KB Output is correct
24 Correct 5 ms 1016 KB Output is correct
25 Correct 5 ms 1144 KB Output is correct
26 Correct 5 ms 1148 KB Output is correct
27 Correct 5 ms 632 KB Output is correct
28 Correct 5 ms 760 KB Output is correct
29 Correct 5 ms 1272 KB Output is correct
30 Correct 5 ms 1272 KB Output is correct
31 Correct 5 ms 1140 KB Output is correct
32 Correct 5 ms 1144 KB Output is correct
33 Correct 6 ms 1272 KB Output is correct
34 Correct 5 ms 1272 KB Output is correct
35 Correct 5 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 760 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 892 KB Output is correct
13 Correct 5 ms 1016 KB Output is correct
14 Correct 5 ms 508 KB Output is correct
15 Correct 5 ms 632 KB Output is correct
16 Correct 5 ms 1016 KB Output is correct
17 Correct 5 ms 1020 KB Output is correct
18 Correct 69 ms 106364 KB Output is correct
19 Correct 41 ms 64760 KB Output is correct
20 Correct 23 ms 34808 KB Output is correct
21 Correct 39 ms 61176 KB Output is correct
22 Correct 48 ms 79224 KB Output is correct
23 Correct 20 ms 29688 KB Output is correct
24 Correct 17 ms 23288 KB Output is correct
25 Correct 20 ms 29048 KB Output is correct
26 Correct 10 ms 11256 KB Output is correct
27 Correct 21 ms 30328 KB Output is correct
28 Correct 16 ms 21752 KB Output is correct
29 Correct 22 ms 30968 KB Output is correct
30 Correct 17 ms 24440 KB Output is correct
31 Correct 20 ms 29048 KB Output is correct
32 Correct 13 ms 15352 KB Output is correct
33 Correct 20 ms 29048 KB Output is correct
34 Correct 10 ms 10616 KB Output is correct
35 Correct 21 ms 28536 KB Output is correct
36 Correct 12 ms 13688 KB Output is correct
37 Correct 22 ms 30328 KB Output is correct
38 Correct 13 ms 16760 KB Output is correct
39 Correct 22 ms 31480 KB Output is correct
40 Correct 14 ms 18680 KB Output is correct
41 Correct 80 ms 131064 KB Output is correct
42 Correct 54 ms 88528 KB Output is correct
43 Correct 81 ms 131064 KB Output is correct
44 Correct 54 ms 87416 KB Output is correct
45 Correct 79 ms 131132 KB Output is correct
46 Correct 54 ms 88568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 760 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 5 ms 1016 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 1016 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 892 KB Output is correct
13 Correct 5 ms 1016 KB Output is correct
14 Correct 5 ms 508 KB Output is correct
15 Correct 5 ms 632 KB Output is correct
16 Correct 5 ms 1016 KB Output is correct
17 Correct 5 ms 1020 KB Output is correct
18 Correct 5 ms 1144 KB Output is correct
19 Correct 5 ms 760 KB Output is correct
20 Correct 5 ms 1016 KB Output is correct
21 Correct 5 ms 1144 KB Output is correct
22 Correct 5 ms 760 KB Output is correct
23 Correct 5 ms 1272 KB Output is correct
24 Correct 5 ms 1016 KB Output is correct
25 Correct 5 ms 1144 KB Output is correct
26 Correct 5 ms 1148 KB Output is correct
27 Correct 5 ms 632 KB Output is correct
28 Correct 5 ms 760 KB Output is correct
29 Correct 5 ms 1272 KB Output is correct
30 Correct 5 ms 1272 KB Output is correct
31 Correct 5 ms 1140 KB Output is correct
32 Correct 5 ms 1144 KB Output is correct
33 Correct 6 ms 1272 KB Output is correct
34 Correct 5 ms 1272 KB Output is correct
35 Correct 5 ms 1272 KB Output is correct
36 Correct 69 ms 106364 KB Output is correct
37 Correct 41 ms 64760 KB Output is correct
38 Correct 23 ms 34808 KB Output is correct
39 Correct 39 ms 61176 KB Output is correct
40 Correct 48 ms 79224 KB Output is correct
41 Correct 20 ms 29688 KB Output is correct
42 Correct 17 ms 23288 KB Output is correct
43 Correct 20 ms 29048 KB Output is correct
44 Correct 10 ms 11256 KB Output is correct
45 Correct 21 ms 30328 KB Output is correct
46 Correct 16 ms 21752 KB Output is correct
47 Correct 22 ms 30968 KB Output is correct
48 Correct 17 ms 24440 KB Output is correct
49 Correct 20 ms 29048 KB Output is correct
50 Correct 13 ms 15352 KB Output is correct
51 Correct 20 ms 29048 KB Output is correct
52 Correct 10 ms 10616 KB Output is correct
53 Correct 21 ms 28536 KB Output is correct
54 Correct 12 ms 13688 KB Output is correct
55 Correct 22 ms 30328 KB Output is correct
56 Correct 13 ms 16760 KB Output is correct
57 Correct 22 ms 31480 KB Output is correct
58 Correct 14 ms 18680 KB Output is correct
59 Correct 80 ms 131064 KB Output is correct
60 Correct 54 ms 88528 KB Output is correct
61 Correct 81 ms 131064 KB Output is correct
62 Correct 54 ms 87416 KB Output is correct
63 Correct 79 ms 131132 KB Output is correct
64 Correct 54 ms 88568 KB Output is correct
65 Correct 74 ms 118392 KB Output is correct
66 Correct 65 ms 108792 KB Output is correct
67 Correct 64 ms 104056 KB Output is correct
68 Correct 60 ms 96120 KB Output is correct
69 Correct 71 ms 117112 KB Output is correct
70 Correct 70 ms 112376 KB Output is correct
71 Correct 69 ms 113528 KB Output is correct
72 Correct 71 ms 114680 KB Output is correct
73 Correct 63 ms 106420 KB Output is correct
74 Correct 63 ms 99448 KB Output is correct
75 Correct 67 ms 109944 KB Output is correct
76 Correct 78 ms 126072 KB Output is correct
77 Correct 76 ms 125920 KB Output is correct
78 Correct 59 ms 97272 KB Output is correct
79 Correct 63 ms 100600 KB Output is correct
80 Correct 75 ms 123384 KB Output is correct
81 Correct 62 ms 101752 KB Output is correct
82 Correct 66 ms 107512 KB Output is correct
83 Correct 81 ms 131064 KB Output is correct
84 Correct 68 ms 112248 KB Output is correct
85 Correct 74 ms 122104 KB Output is correct
86 Correct 74 ms 119672 KB Output is correct
87 Correct 70 ms 109944 KB Output is correct
88 Correct 82 ms 132344 KB Output is correct
89 Correct 80 ms 132344 KB Output is correct
90 Correct 68 ms 111068 KB Output is correct
91 Correct 83 ms 132344 KB Output is correct
92 Correct 82 ms 132344 KB Output is correct
93 Correct 81 ms 129788 KB Output is correct