Submission #707727

# Submission time Handle Problem Language Result Execution time Memory
707727 2023-03-09T21:35:07 Z rainboy Collecting Stamps 3 (JOI20_ho_t3) C
100 / 100
93 ms 65160 KB
#include <stdio.h>

#define N	200
#define INF	0x3f3f3f3f3f3f3f3fLL

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

int dist(int m, int a, int b) {
	int tmp;

	if (a > b)
		tmp = a, a = b, b = tmp;
	return min(b - a, m + a - b);
}

int main() {
	static int xx[N], tt[N];
	static long long dp[N + 1][N + 1][N + 1][2];
	int n, m, i, j, k, k_, s;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%d", &xx[i]);
	for (i = 0; i < n; i++)
		scanf("%d", &tt[i]);
	for (i = 0; i <= n; i++)
		for (j = i; j <= n; j++)
			for (k = 0; k <= n; k++)
				for (s = 0; s < 2; s++)
					dp[i][j][k][s] = INF;
	dp[0][n][0][0] = 0;
	for (i = 0; i <= n; i++)
		for (j = n; j > i; j--)
			for (k = 0; k <= n; k++)
				for (s = 0; s < 2; s++) {
					long long t = dp[i][j][k][s], t_;
					int x = s == 0 ? (i == 0 ? 0 : xx[i - 1]) : (j == n ? 0 : xx[j]);

					if (t == INF)
						continue;
					k_ = k, t_ = t + dist(m, x, xx[i]);
					if (t_ <= tt[i])
						k_++;
					dp[i + 1][j][k_][0] = min(dp[i + 1][j][k_][0], t_);
					k_ = k, t_ = t + dist(m, x, xx[j - 1]);
					if (t_ <= tt[j - 1])
						k_++;
					dp[i][j - 1][k_][1] = min(dp[i][j - 1][k_][1], t_);
				}
	k_ = 0;
	for (i = 0; i <= n; i++)
		for (k = 0; k <= n; k++)
			if (dp[i][i][k][0] != INF || dp[i][i][k][1] != INF)
				k_ = max(k_, k);
	printf("%d\n", k_);
	return 0;
}

Compilation message

ho_t3.c: In function 'main':
ho_t3.c:22:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
ho_t3.c:24:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |   scanf("%d", &xx[i]);
      |   ^~~~~~~~~~~~~~~~~~~
ho_t3.c:26:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%d", &tt[i]);
      |   ^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 596 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 548 KB Output is correct
10 Correct 0 ms 296 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 0 ms 596 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 548 KB Output is correct
17 Correct 0 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 596 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 548 KB Output is correct
10 Correct 0 ms 296 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 0 ms 596 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 548 KB Output is correct
17 Correct 0 ms 596 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 0 ms 596 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 0 ms 468 KB Output is correct
23 Correct 0 ms 724 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 0 ms 596 KB Output is correct
26 Correct 0 ms 596 KB Output is correct
27 Correct 0 ms 420 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 724 KB Output is correct
30 Correct 0 ms 724 KB Output is correct
31 Correct 1 ms 596 KB Output is correct
32 Correct 1 ms 596 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 1 ms 680 KB Output is correct
35 Correct 0 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 596 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 548 KB Output is correct
10 Correct 0 ms 296 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 0 ms 596 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 548 KB Output is correct
17 Correct 0 ms 596 KB Output is correct
18 Correct 56 ms 52308 KB Output is correct
19 Correct 31 ms 31864 KB Output is correct
20 Correct 14 ms 17060 KB Output is correct
21 Correct 27 ms 30124 KB Output is correct
22 Correct 40 ms 38868 KB Output is correct
23 Correct 13 ms 14548 KB Output is correct
24 Correct 7 ms 11476 KB Output is correct
25 Correct 12 ms 14292 KB Output is correct
26 Correct 3 ms 5548 KB Output is correct
27 Correct 13 ms 14932 KB Output is correct
28 Correct 7 ms 10660 KB Output is correct
29 Correct 12 ms 15188 KB Output is correct
30 Correct 8 ms 11988 KB Output is correct
31 Correct 13 ms 14340 KB Output is correct
32 Correct 5 ms 7636 KB Output is correct
33 Correct 12 ms 14248 KB Output is correct
34 Correct 4 ms 5264 KB Output is correct
35 Correct 9 ms 14036 KB Output is correct
36 Correct 4 ms 6740 KB Output is correct
37 Correct 9 ms 14888 KB Output is correct
38 Correct 5 ms 8276 KB Output is correct
39 Correct 10 ms 15464 KB Output is correct
40 Correct 5 ms 9172 KB Output is correct
41 Correct 79 ms 64344 KB Output is correct
42 Correct 28 ms 43448 KB Output is correct
43 Correct 81 ms 64428 KB Output is correct
44 Correct 27 ms 42964 KB Output is correct
45 Correct 88 ms 64540 KB Output is correct
46 Correct 27 ms 43500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 296 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 596 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 468 KB Output is correct
9 Correct 0 ms 548 KB Output is correct
10 Correct 0 ms 296 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 0 ms 596 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 548 KB Output is correct
17 Correct 0 ms 596 KB Output is correct
18 Correct 1 ms 596 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 0 ms 596 KB Output is correct
21 Correct 1 ms 596 KB Output is correct
22 Correct 0 ms 468 KB Output is correct
23 Correct 0 ms 724 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 0 ms 596 KB Output is correct
26 Correct 0 ms 596 KB Output is correct
27 Correct 0 ms 420 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 724 KB Output is correct
30 Correct 0 ms 724 KB Output is correct
31 Correct 1 ms 596 KB Output is correct
32 Correct 1 ms 596 KB Output is correct
33 Correct 1 ms 724 KB Output is correct
34 Correct 1 ms 680 KB Output is correct
35 Correct 0 ms 724 KB Output is correct
36 Correct 56 ms 52308 KB Output is correct
37 Correct 31 ms 31864 KB Output is correct
38 Correct 14 ms 17060 KB Output is correct
39 Correct 27 ms 30124 KB Output is correct
40 Correct 40 ms 38868 KB Output is correct
41 Correct 13 ms 14548 KB Output is correct
42 Correct 7 ms 11476 KB Output is correct
43 Correct 12 ms 14292 KB Output is correct
44 Correct 3 ms 5548 KB Output is correct
45 Correct 13 ms 14932 KB Output is correct
46 Correct 7 ms 10660 KB Output is correct
47 Correct 12 ms 15188 KB Output is correct
48 Correct 8 ms 11988 KB Output is correct
49 Correct 13 ms 14340 KB Output is correct
50 Correct 5 ms 7636 KB Output is correct
51 Correct 12 ms 14248 KB Output is correct
52 Correct 4 ms 5264 KB Output is correct
53 Correct 9 ms 14036 KB Output is correct
54 Correct 4 ms 6740 KB Output is correct
55 Correct 9 ms 14888 KB Output is correct
56 Correct 5 ms 8276 KB Output is correct
57 Correct 10 ms 15464 KB Output is correct
58 Correct 5 ms 9172 KB Output is correct
59 Correct 79 ms 64344 KB Output is correct
60 Correct 28 ms 43448 KB Output is correct
61 Correct 81 ms 64428 KB Output is correct
62 Correct 27 ms 42964 KB Output is correct
63 Correct 88 ms 64540 KB Output is correct
64 Correct 27 ms 43500 KB Output is correct
65 Correct 70 ms 58152 KB Output is correct
66 Correct 63 ms 53460 KB Output is correct
67 Correct 58 ms 51164 KB Output is correct
68 Correct 49 ms 47276 KB Output is correct
69 Correct 71 ms 57608 KB Output is correct
70 Correct 67 ms 55216 KB Output is correct
71 Correct 58 ms 55732 KB Output is correct
72 Correct 71 ms 56384 KB Output is correct
73 Correct 46 ms 52260 KB Output is correct
74 Correct 57 ms 48932 KB Output is correct
75 Correct 56 ms 53972 KB Output is correct
76 Correct 82 ms 61880 KB Output is correct
77 Correct 69 ms 61908 KB Output is correct
78 Correct 60 ms 47824 KB Output is correct
79 Correct 55 ms 49412 KB Output is correct
80 Correct 79 ms 60664 KB Output is correct
81 Correct 52 ms 50004 KB Output is correct
82 Correct 49 ms 52884 KB Output is correct
83 Correct 75 ms 64332 KB Output is correct
84 Correct 53 ms 55252 KB Output is correct
85 Correct 64 ms 59968 KB Output is correct
86 Correct 57 ms 58812 KB Output is correct
87 Correct 62 ms 54048 KB Output is correct
88 Correct 91 ms 65064 KB Output is correct
89 Correct 81 ms 64956 KB Output is correct
90 Correct 36 ms 54536 KB Output is correct
91 Correct 93 ms 65160 KB Output is correct
92 Correct 79 ms 65020 KB Output is correct
93 Correct 41 ms 63792 KB Output is correct