Submission #257045

# Submission time Handle Problem Language Result Execution time Memory
257045 2020-08-03T14:39:48 Z akat Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
112 ms 127736 KB
#include<bits/stdc++.h>
using namespace std;
const long long N = 201;
long long t[N], x[N], ans;
long long dp[N][N][N][2];
void update(long long l,long long r,long long cnt,long long j,long long time)
{
	long long cur = l;
	if(j) cur = r;
	if(t[cur] >= time) cnt++;
	long long &curr = dp[l][r][cnt][j];
	if(curr == -1 || curr > time) curr = time;
	ans = max(ans, cnt);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long n, la, i, j, k;
	cin>>n>>la;
	for(i = 1; i <= n; i++)
		cin>>x[i];
	for(i = 1; i <= n; i++)
		cin>>t[i];
	memset(dp, -1, sizeof(dp));
	x[0] = 0;
	update(1, n, 0, 0, x[1]);
	update(1, n, 0, 1, la - x[n]);
	for(i = 1; i <= n; i++)
		for(j = 1; j <= i; j++)
			for(k = 0; k <= i; k++)
			{
				long long l = j;
				long long r = n - i + j;
				if(l >= r) continue;
				if(dp[l][r][k][0] != -1)
				{
					long long time = dp[l][r][k][0];
					update(l+1, r, k, 0, time + x[l+1] - x[l]);
					update(l+1, r, k, 1, time + x[l] + la - x[r]);
				}
				if(dp[l][r][k][1] != -1)
				{
					long long time = dp[l][r][k][1];
					update(l, r-1, k, 1, time + x[r] - x[r-1]);
					update(l, r-1, k, 0, time + la - x[r] + x[l]);
				}
			}
	cout<<ans<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 64 ms 127480 KB Output is correct
2 Correct 69 ms 127480 KB Output is correct
3 Correct 73 ms 127480 KB Output is correct
4 Correct 69 ms 127480 KB Output is correct
5 Correct 68 ms 127480 KB Output is correct
6 Correct 62 ms 127480 KB Output is correct
7 Correct 63 ms 127576 KB Output is correct
8 Correct 62 ms 127480 KB Output is correct
9 Correct 63 ms 127508 KB Output is correct
10 Correct 65 ms 127480 KB Output is correct
11 Correct 69 ms 127480 KB Output is correct
12 Correct 65 ms 127480 KB Output is correct
13 Correct 63 ms 127480 KB Output is correct
14 Correct 69 ms 127480 KB Output is correct
15 Correct 65 ms 127480 KB Output is correct
16 Correct 62 ms 127480 KB Output is correct
17 Correct 62 ms 127480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 127480 KB Output is correct
2 Correct 69 ms 127480 KB Output is correct
3 Correct 73 ms 127480 KB Output is correct
4 Correct 69 ms 127480 KB Output is correct
5 Correct 68 ms 127480 KB Output is correct
6 Correct 62 ms 127480 KB Output is correct
7 Correct 63 ms 127576 KB Output is correct
8 Correct 62 ms 127480 KB Output is correct
9 Correct 63 ms 127508 KB Output is correct
10 Correct 65 ms 127480 KB Output is correct
11 Correct 69 ms 127480 KB Output is correct
12 Correct 65 ms 127480 KB Output is correct
13 Correct 63 ms 127480 KB Output is correct
14 Correct 69 ms 127480 KB Output is correct
15 Correct 65 ms 127480 KB Output is correct
16 Correct 62 ms 127480 KB Output is correct
17 Correct 62 ms 127480 KB Output is correct
18 Correct 63 ms 127480 KB Output is correct
19 Correct 63 ms 127608 KB Output is correct
20 Correct 63 ms 127480 KB Output is correct
21 Correct 63 ms 127480 KB Output is correct
22 Correct 63 ms 127480 KB Output is correct
23 Correct 62 ms 127480 KB Output is correct
24 Correct 64 ms 127480 KB Output is correct
25 Correct 64 ms 127452 KB Output is correct
26 Correct 64 ms 127480 KB Output is correct
27 Correct 65 ms 127480 KB Output is correct
28 Correct 64 ms 127480 KB Output is correct
29 Correct 64 ms 127608 KB Output is correct
30 Correct 63 ms 127480 KB Output is correct
31 Correct 62 ms 127480 KB Output is correct
32 Correct 66 ms 127480 KB Output is correct
33 Correct 62 ms 127480 KB Output is correct
34 Correct 62 ms 127480 KB Output is correct
35 Correct 63 ms 127484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 127480 KB Output is correct
2 Correct 69 ms 127480 KB Output is correct
3 Correct 73 ms 127480 KB Output is correct
4 Correct 69 ms 127480 KB Output is correct
5 Correct 68 ms 127480 KB Output is correct
6 Correct 62 ms 127480 KB Output is correct
7 Correct 63 ms 127576 KB Output is correct
8 Correct 62 ms 127480 KB Output is correct
9 Correct 63 ms 127508 KB Output is correct
10 Correct 65 ms 127480 KB Output is correct
11 Correct 69 ms 127480 KB Output is correct
12 Correct 65 ms 127480 KB Output is correct
13 Correct 63 ms 127480 KB Output is correct
14 Correct 69 ms 127480 KB Output is correct
15 Correct 65 ms 127480 KB Output is correct
16 Correct 62 ms 127480 KB Output is correct
17 Correct 62 ms 127480 KB Output is correct
18 Correct 87 ms 127480 KB Output is correct
19 Correct 77 ms 127472 KB Output is correct
20 Correct 69 ms 127480 KB Output is correct
21 Correct 76 ms 127480 KB Output is correct
22 Correct 82 ms 127480 KB Output is correct
23 Correct 68 ms 127480 KB Output is correct
24 Correct 64 ms 127480 KB Output is correct
25 Correct 68 ms 127480 KB Output is correct
26 Correct 64 ms 127484 KB Output is correct
27 Correct 69 ms 127480 KB Output is correct
28 Correct 65 ms 127480 KB Output is correct
29 Correct 70 ms 127480 KB Output is correct
30 Correct 65 ms 127520 KB Output is correct
31 Correct 67 ms 127480 KB Output is correct
32 Correct 64 ms 127480 KB Output is correct
33 Correct 69 ms 127480 KB Output is correct
34 Correct 63 ms 127480 KB Output is correct
35 Correct 67 ms 127480 KB Output is correct
36 Correct 64 ms 127480 KB Output is correct
37 Correct 66 ms 127480 KB Output is correct
38 Correct 66 ms 127484 KB Output is correct
39 Correct 66 ms 127480 KB Output is correct
40 Correct 65 ms 127480 KB Output is correct
41 Correct 103 ms 127608 KB Output is correct
42 Correct 68 ms 127480 KB Output is correct
43 Correct 111 ms 127480 KB Output is correct
44 Correct 72 ms 127480 KB Output is correct
45 Correct 104 ms 127480 KB Output is correct
46 Correct 77 ms 127480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 127480 KB Output is correct
2 Correct 69 ms 127480 KB Output is correct
3 Correct 73 ms 127480 KB Output is correct
4 Correct 69 ms 127480 KB Output is correct
5 Correct 68 ms 127480 KB Output is correct
6 Correct 62 ms 127480 KB Output is correct
7 Correct 63 ms 127576 KB Output is correct
8 Correct 62 ms 127480 KB Output is correct
9 Correct 63 ms 127508 KB Output is correct
10 Correct 65 ms 127480 KB Output is correct
11 Correct 69 ms 127480 KB Output is correct
12 Correct 65 ms 127480 KB Output is correct
13 Correct 63 ms 127480 KB Output is correct
14 Correct 69 ms 127480 KB Output is correct
15 Correct 65 ms 127480 KB Output is correct
16 Correct 62 ms 127480 KB Output is correct
17 Correct 62 ms 127480 KB Output is correct
18 Correct 63 ms 127480 KB Output is correct
19 Correct 63 ms 127608 KB Output is correct
20 Correct 63 ms 127480 KB Output is correct
21 Correct 63 ms 127480 KB Output is correct
22 Correct 63 ms 127480 KB Output is correct
23 Correct 62 ms 127480 KB Output is correct
24 Correct 64 ms 127480 KB Output is correct
25 Correct 64 ms 127452 KB Output is correct
26 Correct 64 ms 127480 KB Output is correct
27 Correct 65 ms 127480 KB Output is correct
28 Correct 64 ms 127480 KB Output is correct
29 Correct 64 ms 127608 KB Output is correct
30 Correct 63 ms 127480 KB Output is correct
31 Correct 62 ms 127480 KB Output is correct
32 Correct 66 ms 127480 KB Output is correct
33 Correct 62 ms 127480 KB Output is correct
34 Correct 62 ms 127480 KB Output is correct
35 Correct 63 ms 127484 KB Output is correct
36 Correct 87 ms 127480 KB Output is correct
37 Correct 77 ms 127472 KB Output is correct
38 Correct 69 ms 127480 KB Output is correct
39 Correct 76 ms 127480 KB Output is correct
40 Correct 82 ms 127480 KB Output is correct
41 Correct 68 ms 127480 KB Output is correct
42 Correct 64 ms 127480 KB Output is correct
43 Correct 68 ms 127480 KB Output is correct
44 Correct 64 ms 127484 KB Output is correct
45 Correct 69 ms 127480 KB Output is correct
46 Correct 65 ms 127480 KB Output is correct
47 Correct 70 ms 127480 KB Output is correct
48 Correct 65 ms 127520 KB Output is correct
49 Correct 67 ms 127480 KB Output is correct
50 Correct 64 ms 127480 KB Output is correct
51 Correct 69 ms 127480 KB Output is correct
52 Correct 63 ms 127480 KB Output is correct
53 Correct 67 ms 127480 KB Output is correct
54 Correct 64 ms 127480 KB Output is correct
55 Correct 66 ms 127480 KB Output is correct
56 Correct 66 ms 127484 KB Output is correct
57 Correct 66 ms 127480 KB Output is correct
58 Correct 65 ms 127480 KB Output is correct
59 Correct 103 ms 127608 KB Output is correct
60 Correct 68 ms 127480 KB Output is correct
61 Correct 111 ms 127480 KB Output is correct
62 Correct 72 ms 127480 KB Output is correct
63 Correct 104 ms 127480 KB Output is correct
64 Correct 77 ms 127480 KB Output is correct
65 Correct 97 ms 127480 KB Output is correct
66 Correct 92 ms 127512 KB Output is correct
67 Correct 89 ms 127480 KB Output is correct
68 Correct 87 ms 127480 KB Output is correct
69 Correct 97 ms 127480 KB Output is correct
70 Correct 97 ms 127608 KB Output is correct
71 Correct 91 ms 127480 KB Output is correct
72 Correct 102 ms 127608 KB Output is correct
73 Correct 80 ms 127588 KB Output is correct
74 Correct 92 ms 127480 KB Output is correct
75 Correct 88 ms 127480 KB Output is correct
76 Correct 102 ms 127480 KB Output is correct
77 Correct 92 ms 127480 KB Output is correct
78 Correct 89 ms 127608 KB Output is correct
79 Correct 88 ms 127480 KB Output is correct
80 Correct 100 ms 127480 KB Output is correct
81 Correct 86 ms 127480 KB Output is correct
82 Correct 85 ms 127480 KB Output is correct
83 Correct 98 ms 127480 KB Output is correct
84 Correct 84 ms 127480 KB Output is correct
85 Correct 87 ms 127480 KB Output is correct
86 Correct 85 ms 127480 KB Output is correct
87 Correct 94 ms 127736 KB Output is correct
88 Correct 111 ms 127480 KB Output is correct
89 Correct 102 ms 127480 KB Output is correct
90 Correct 72 ms 127420 KB Output is correct
91 Correct 112 ms 127520 KB Output is correct
92 Correct 100 ms 127480 KB Output is correct
93 Correct 81 ms 127504 KB Output is correct