Submission #244944

# Submission time Handle Problem Language Result Execution time Memory
244944 2020-07-05T09:47:00 Z maximath_1 Collecting Stamps 3 (JOI20_ho_t3) C++11
15 / 100
89 ms 65424 KB
#include <bits/stdc++.h>
using namespace std;

const int inf = 2e9 + 69;
int x[205], t[205], n, l, dp[205][205][205][2];

int main(){
	scanf("%d%d", &n, &l);
	for(int i = 1; i <= n; i ++) scanf("%d", &x[i]);
	for(int i = 1; i <= n; i ++) scanf("%d", &t[i]);
	x[n + 1] = l;
	
	for(int i = 0; i <= n; i ++) for(int j = 0; j <= n; j ++) for(int k = 0; k <= n; k ++) for(int a = 0; a < 2; a ++)
		dp[i][j][k][a] = inf + 5;
	dp[0][0][0][0] = dp[0][0][0][1] = 0;

	for(int i = 0; i < n; i ++) for(int j = 0; i + j < n; j ++) for(int k = 0; k <= i + j; k ++){
		int tim;
		if(dp[i][j][k][0] < inf){
			tim = dp[i][j][k][0] + x[i + 1] - x[i];
			dp[i + 1][j][k + (t[i + 1] >= tim)][0] = min(dp[i + 1][j][k + (t[i + 1] >= tim)][0], tim);

			tim = dp[i][j][k][0] + x[i] + l - x[n - j];
			dp[i][j + 1][k + (t[n - j] >= tim)][1] = min(dp[i][j + 1][k + (t[n - j] >= tim)][1], tim);
		}

		if(dp[i][j][k][1] < inf){
			tim = dp[i][j][k][1] + x[n - j + 1] - x[n -j];
			dp[i][j + 1][k + (t[n - j] >= tim)][1] = min(dp[i][j + 1][k + (t[n - j] >= tim)][1], tim);

			tim = dp[i][j][k][1] + l - x[n - j + 1] + x[i + 1];
			dp[i + 1][j][k + (t[i + 1] >= tim)][0] = min(dp[i + 1][j][k + (t[i + 1] >= tim)][0], tim);
		}
	}

	int ans = 0;
	for(int i = 0; i <= n; i ++) for(int j = 0; i + j <= n; j ++) for(int k = 0; k <= i + j; k ++){
		if(min(dp[i][j][k][0], dp[i][j][k][1]) < inf)
			ans = max(ans, k);
	}

	printf("%d\n", ans);
	return 0;
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &l);
  ~~~~~^~~~~~~~~~~~~~~~
ho_t3.cpp:9:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i <= n; i ++) scanf("%d", &x[i]);
                               ~~~~~^~~~~~~~~~~~~
ho_t3.cpp:10:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 1; i <= n; i ++) scanf("%d", &t[i]);
                               ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 640 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 640 KB Output is correct
9 Correct 5 ms 640 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 640 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 640 KB Output is correct
17 Correct 5 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 640 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 640 KB Output is correct
9 Correct 5 ms 640 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 640 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 640 KB Output is correct
17 Correct 5 ms 640 KB Output is correct
18 Incorrect 5 ms 768 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 640 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 640 KB Output is correct
9 Correct 5 ms 640 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 640 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 640 KB Output is correct
17 Correct 5 ms 640 KB Output is correct
18 Correct 63 ms 52984 KB Output is correct
19 Correct 36 ms 32256 KB Output is correct
20 Correct 23 ms 17528 KB Output is correct
21 Correct 36 ms 30592 KB Output is correct
22 Correct 46 ms 39424 KB Output is correct
23 Correct 18 ms 14848 KB Output is correct
24 Correct 12 ms 11648 KB Output is correct
25 Correct 18 ms 14464 KB Output is correct
26 Correct 8 ms 5760 KB Output is correct
27 Correct 19 ms 15104 KB Output is correct
28 Correct 13 ms 10880 KB Output is correct
29 Correct 17 ms 15488 KB Output is correct
30 Correct 13 ms 12160 KB Output is correct
31 Correct 17 ms 14464 KB Output is correct
32 Correct 10 ms 7808 KB Output is correct
33 Correct 17 ms 14464 KB Output is correct
34 Correct 10 ms 5376 KB Output is correct
35 Correct 13 ms 14208 KB Output is correct
36 Correct 9 ms 6912 KB Output is correct
37 Correct 14 ms 15104 KB Output is correct
38 Correct 10 ms 8448 KB Output is correct
39 Correct 15 ms 15744 KB Output is correct
40 Correct 10 ms 9344 KB Output is correct
41 Correct 84 ms 65400 KB Output is correct
42 Correct 33 ms 44160 KB Output is correct
43 Correct 86 ms 65424 KB Output is correct
44 Correct 34 ms 43648 KB Output is correct
45 Correct 89 ms 65400 KB Output is correct
46 Correct 32 ms 44152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 640 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 640 KB Output is correct
9 Correct 5 ms 640 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 640 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 640 KB Output is correct
17 Correct 5 ms 640 KB Output is correct
18 Incorrect 5 ms 768 KB Output isn't correct
19 Halted 0 ms 0 KB -