# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
224054 | 2020-04-17T06:34:12 Z | jamielim | Collecting Stamps 3 (JOI20_ho_t3) | C++14 | 179 ms | 128888 KB |
#include <bits/stdc++.h> using namespace std; const long long INF=1012345678012345LL; int main(){ int n;long long l; scanf("%d%lld",&n,&l); long long x[n+2],t[n+2]; x[0]=0;x[n+1]=l;t[0]=t[n+1]=INF; for(int i=1;i<=n;i++)scanf("%lld",&x[i]); for(int i=1;i<=n;i++)scanf("%lld",&t[i]); long long dp[n+2][n+2][n+1][2]; //time for(int i=0;i<n+2;i++){ for(int j=0;j<n+2;j++){ for(int k=0;k<=n;k++)dp[i][j][k][0]=dp[i][j][k][1]=INF; } } dp[0][n+1][0][0]=0;dp[0][n+1][0][1]=0; for(int k=0;k<=n;k++){ for(int i=0;i<=n;i++){ for(int j=n+1;j>i;j--){ if(i>0){ if(k>0){ if(dp[i-1][j][k-1][0]<INF&&dp[i-1][j][k-1][0]+x[i]-x[i-1]<=t[i]) dp[i][j][k][0]=min(dp[i][j][k][0],dp[i-1][j][k-1][0]+x[i]-x[i-1]); if(dp[i-1][j][k-1][1]<INF&&dp[i-1][j][k-1][1]+l-(x[j]-x[i])<=t[i]) dp[i][j][k][0]=min(dp[i][j][k][0],dp[i-1][j][k-1][1]+l-(x[j]-x[i])); } if(dp[i-1][j][k][0]<INF)dp[i][j][k][0]=min(dp[i][j][k][0],dp[i-1][j][k][0]+x[i]-x[i-1]); if(dp[i-1][j][k][1]<INF)dp[i][j][k][0]=min(dp[i][j][k][0],dp[i-1][j][k][1]+l-(x[j]-x[i])); } if(j<n+1){ if(k>0){ if(dp[i][j+1][k-1][0]<INF&&dp[i][j+1][k-1][0]+l-(x[j]-x[i])<=t[j]) dp[i][j][k][1]=min(dp[i][j][k][1],dp[i][j+1][k-1][0]+l-(x[j]-x[i])); if(dp[i][j+1][k-1][1]<INF&&dp[i][j+1][k-1][1]+x[j+1]-x[j]<=t[j]) dp[i][j][k][1]=min(dp[i][j][k][1],dp[i][j+1][k-1][1]+x[j+1]-x[j]); } if(dp[i][j+1][k][0]<INF)dp[i][j][k][1]=min(dp[i][j][k][1],dp[i][j+1][k][0]+l-(x[j]-x[i])); if(dp[i][j+1][k][1]<INF)dp[i][j][k][1]=min(dp[i][j][k][1],dp[i][j+1][k][1]+x[j+1]-x[j]); } //printf("%lld %lld ",dp[i][j][0],dp[i][j][1]); //dp[i][j][k][0]=min(dp[i][j][k][0],dp[i][j][k][1]+l-(x[j]-x[i])); //dp[i][j][k][1]=min(dp[i][j][k][1],dp[i][j][k][0]+l-(x[j]-x[i])); //printf("%lld %lld\n",dp[i][j][0],dp[i][j][1]); } //printf("\n"); } } int ans=0; for(int i=0;i<n+2;i++){ for(int j=0;j<n+2;j++){ for(int k=0;k<=n;k++){ if(dp[i][j][k][0]<INF||dp[i][j][k][1]<INF){ ans=max(ans,k); } } } } //for(int i=0;i<n+2;i++){for(int j=0;j<n+2;j++)printf("%lld ",dp[i][j][0]);printf("\n");} //for(int i=0;i<n+2;i++){for(int j=0;j<n+2;j++)printf("%lld ",dp[i][j][1]);printf("\n");} printf("%d",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 4 ms | 256 KB | Output is correct |
16 | Correct | 4 ms | 384 KB | Output is correct |
17 | Correct | 4 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 4 ms | 256 KB | Output is correct |
16 | Correct | 4 ms | 384 KB | Output is correct |
17 | Correct | 4 ms | 384 KB | Output is correct |
18 | Correct | 4 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 512 KB | Output is correct |
20 | Correct | 4 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 4 ms | 384 KB | Output is correct |
23 | Correct | 4 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
28 | Correct | 6 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 5 ms | 384 KB | Output is correct |
31 | Correct | 4 ms | 384 KB | Output is correct |
32 | Correct | 5 ms | 384 KB | Output is correct |
33 | Correct | 4 ms | 384 KB | Output is correct |
34 | Correct | 4 ms | 384 KB | Output is correct |
35 | Correct | 4 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 4 ms | 256 KB | Output is correct |
16 | Correct | 4 ms | 384 KB | Output is correct |
17 | Correct | 4 ms | 384 KB | Output is correct |
18 | Correct | 106 ms | 92664 KB | Output is correct |
19 | Correct | 56 ms | 43904 KB | Output is correct |
20 | Correct | 25 ms | 17280 KB | Output is correct |
21 | Correct | 51 ms | 40320 KB | Output is correct |
22 | Correct | 75 ms | 59392 KB | Output is correct |
23 | Correct | 23 ms | 13568 KB | Output is correct |
24 | Correct | 14 ms | 9472 KB | Output is correct |
25 | Correct | 23 ms | 13184 KB | Output is correct |
26 | Correct | 17 ms | 3328 KB | Output is correct |
27 | Correct | 25 ms | 14080 KB | Output is correct |
28 | Correct | 13 ms | 8576 KB | Output is correct |
29 | Correct | 23 ms | 14464 KB | Output is correct |
30 | Correct | 15 ms | 10240 KB | Output is correct |
31 | Correct | 20 ms | 13184 KB | Output is correct |
32 | Correct | 10 ms | 5120 KB | Output is correct |
33 | Correct | 23 ms | 13184 KB | Output is correct |
34 | Correct | 10 ms | 3072 KB | Output is correct |
35 | Correct | 24 ms | 12800 KB | Output is correct |
36 | Correct | 8 ms | 4480 KB | Output is correct |
37 | Correct | 19 ms | 14080 KB | Output is correct |
38 | Correct | 11 ms | 5888 KB | Output is correct |
39 | Correct | 20 ms | 14848 KB | Output is correct |
40 | Correct | 13 ms | 6784 KB | Output is correct |
41 | Correct | 160 ms | 126840 KB | Output is correct |
42 | Correct | 70 ms | 70136 KB | Output is correct |
43 | Correct | 179 ms | 126840 KB | Output is correct |
44 | Correct | 69 ms | 68992 KB | Output is correct |
45 | Correct | 159 ms | 126968 KB | Output is correct |
46 | Correct | 68 ms | 70264 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 256 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 4 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 4 ms | 256 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
12 | Correct | 5 ms | 384 KB | Output is correct |
13 | Correct | 4 ms | 384 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 4 ms | 256 KB | Output is correct |
16 | Correct | 4 ms | 384 KB | Output is correct |
17 | Correct | 4 ms | 384 KB | Output is correct |
18 | Correct | 4 ms | 384 KB | Output is correct |
19 | Correct | 5 ms | 512 KB | Output is correct |
20 | Correct | 4 ms | 384 KB | Output is correct |
21 | Correct | 5 ms | 384 KB | Output is correct |
22 | Correct | 4 ms | 384 KB | Output is correct |
23 | Correct | 4 ms | 384 KB | Output is correct |
24 | Correct | 5 ms | 384 KB | Output is correct |
25 | Correct | 5 ms | 384 KB | Output is correct |
26 | Correct | 5 ms | 384 KB | Output is correct |
27 | Correct | 5 ms | 384 KB | Output is correct |
28 | Correct | 6 ms | 384 KB | Output is correct |
29 | Correct | 5 ms | 384 KB | Output is correct |
30 | Correct | 5 ms | 384 KB | Output is correct |
31 | Correct | 4 ms | 384 KB | Output is correct |
32 | Correct | 5 ms | 384 KB | Output is correct |
33 | Correct | 4 ms | 384 KB | Output is correct |
34 | Correct | 4 ms | 384 KB | Output is correct |
35 | Correct | 4 ms | 384 KB | Output is correct |
36 | Correct | 106 ms | 92664 KB | Output is correct |
37 | Correct | 56 ms | 43904 KB | Output is correct |
38 | Correct | 25 ms | 17280 KB | Output is correct |
39 | Correct | 51 ms | 40320 KB | Output is correct |
40 | Correct | 75 ms | 59392 KB | Output is correct |
41 | Correct | 23 ms | 13568 KB | Output is correct |
42 | Correct | 14 ms | 9472 KB | Output is correct |
43 | Correct | 23 ms | 13184 KB | Output is correct |
44 | Correct | 17 ms | 3328 KB | Output is correct |
45 | Correct | 25 ms | 14080 KB | Output is correct |
46 | Correct | 13 ms | 8576 KB | Output is correct |
47 | Correct | 23 ms | 14464 KB | Output is correct |
48 | Correct | 15 ms | 10240 KB | Output is correct |
49 | Correct | 20 ms | 13184 KB | Output is correct |
50 | Correct | 10 ms | 5120 KB | Output is correct |
51 | Correct | 23 ms | 13184 KB | Output is correct |
52 | Correct | 10 ms | 3072 KB | Output is correct |
53 | Correct | 24 ms | 12800 KB | Output is correct |
54 | Correct | 8 ms | 4480 KB | Output is correct |
55 | Correct | 19 ms | 14080 KB | Output is correct |
56 | Correct | 11 ms | 5888 KB | Output is correct |
57 | Correct | 20 ms | 14848 KB | Output is correct |
58 | Correct | 13 ms | 6784 KB | Output is correct |
59 | Correct | 160 ms | 126840 KB | Output is correct |
60 | Correct | 70 ms | 70136 KB | Output is correct |
61 | Correct | 179 ms | 126840 KB | Output is correct |
62 | Correct | 69 ms | 68992 KB | Output is correct |
63 | Correct | 159 ms | 126968 KB | Output is correct |
64 | Correct | 68 ms | 70264 KB | Output is correct |
65 | Correct | 126 ms | 108792 KB | Output is correct |
66 | Correct | 113 ms | 95672 KB | Output is correct |
67 | Correct | 107 ms | 89592 KB | Output is correct |
68 | Correct | 95 ms | 79556 KB | Output is correct |
69 | Correct | 126 ms | 107128 KB | Output is correct |
70 | Correct | 141 ms | 100472 KB | Output is correct |
71 | Correct | 112 ms | 102264 KB | Output is correct |
72 | Correct | 143 ms | 103800 KB | Output is correct |
73 | Correct | 96 ms | 92664 KB | Output is correct |
74 | Correct | 119 ms | 83832 KB | Output is correct |
75 | Correct | 106 ms | 97272 KB | Output is correct |
76 | Correct | 151 ms | 119544 KB | Output is correct |
77 | Correct | 129 ms | 119420 KB | Output is correct |
78 | Correct | 107 ms | 80888 KB | Output is correct |
79 | Correct | 102 ms | 85240 KB | Output is correct |
80 | Correct | 151 ms | 115808 KB | Output is correct |
81 | Correct | 101 ms | 86648 KB | Output is correct |
82 | Correct | 107 ms | 94200 KB | Output is correct |
83 | Correct | 140 ms | 126840 KB | Output is correct |
84 | Correct | 112 ms | 100472 KB | Output is correct |
85 | Correct | 117 ms | 114040 KB | Output is correct |
86 | Correct | 127 ms | 110508 KB | Output is correct |
87 | Correct | 114 ms | 97400 KB | Output is correct |
88 | Correct | 171 ms | 128888 KB | Output is correct |
89 | Correct | 160 ms | 128760 KB | Output is correct |
90 | Correct | 97 ms | 99064 KB | Output is correct |
91 | Correct | 168 ms | 128760 KB | Output is correct |
92 | Correct | 161 ms | 128760 KB | Output is correct |
93 | Correct | 119 ms | 124920 KB | Output is correct |