# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
548487 | 2022-04-13T14:18:52 Z | krit3379 | Collecting Stamps 3 (JOI20_ho_t3) | C++17 | 126 ms | 132852 KB |
#include<bits/stdc++.h> using namespace std; #define N 205 int x[N],rev[N],t[N],ans; long long dp[2][N][N][N]; int main(){ int n,m,l,i,j,k; scanf("%d %d",&n,&l); for(i=1;i<=n;i++)scanf("%d",&x[i]),rev[n-i+1]=l-x[i]; for(i=1;i<=n;i++)scanf("%d",&t[i]); for(i=0;i<=n+1;i++)for(j=0;j<=n+1;j++)for(k=0;k<=n+1;k++)dp[0][i][j][k]=dp[1][i][j][k]=1e18; dp[1][0][0][0]=dp[0][0][0][0]=0; //dp[][i][j][k] collect i stamp at j-th left and k-th right //dp[0]->left dp[1]->right for(i=0;i<=n;i++)for(j=0;j<=n;j++)for(k=0;k<=n;k++){ if(j+k>n)continue; if(j)dp[0][i][j][k]=min({dp[0][i][j][k],dp[0][i][j-1][k]+rev[j]-rev[j-1],dp[1][i][j-1][k]+rev[j]+x[k]}); if(k)dp[1][i][j][k]=min({dp[1][i][j][k],dp[1][i][j][k-1]+x[k]-x[k-1],dp[0][i][j][k-1]+rev[j]+x[k]}); if(i&&j&&min(dp[0][i-1][j-1][k]+rev[j]-rev[j-1],dp[1][i-1][j-1][k]+rev[j]+x[k])<=t[n-j+1])dp[0][i][j][k]=min({dp[0][i][j][k],dp[0][i-1][j-1][k]+rev[j]-rev[j-1],dp[1][i-1][j-1][k]+rev[j]+x[k]}); if(i&&k&&min(dp[1][i-1][j][k-1]+x[k]-x[k-1],dp[0][i-1][j][k-1]+rev[j]+x[k])<=t[k])dp[1][i][j][k]=min({dp[1][i][j][k],dp[1][i-1][j][k-1]+x[k]-x[k-1],dp[0][i-1][j][k-1]+rev[j]+x[k]}); if(dp[0][i][j][k]<1e18||dp[1][i][j][k]<1e18)ans=max(ans,i); } printf("%d",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | Output is correct |
2 | Correct | 1 ms | 436 KB | Output is correct |
3 | Correct | 1 ms | 724 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 596 KB | Output is correct |
6 | Correct | 1 ms | 980 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 1 ms | 828 KB | Output is correct |
9 | Correct | 1 ms | 980 KB | Output is correct |
10 | Correct | 1 ms | 308 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 980 KB | Output is correct |
13 | Correct | 1 ms | 980 KB | Output is correct |
14 | Correct | 1 ms | 596 KB | Output is correct |
15 | Correct | 1 ms | 596 KB | Output is correct |
16 | Correct | 1 ms | 980 KB | Output is correct |
17 | Correct | 1 ms | 980 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | Output is correct |
2 | Correct | 1 ms | 436 KB | Output is correct |
3 | Correct | 1 ms | 724 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 596 KB | Output is correct |
6 | Correct | 1 ms | 980 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 1 ms | 828 KB | Output is correct |
9 | Correct | 1 ms | 980 KB | Output is correct |
10 | Correct | 1 ms | 308 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 980 KB | Output is correct |
13 | Correct | 1 ms | 980 KB | Output is correct |
14 | Correct | 1 ms | 596 KB | Output is correct |
15 | Correct | 1 ms | 596 KB | Output is correct |
16 | Correct | 1 ms | 980 KB | Output is correct |
17 | Correct | 1 ms | 980 KB | Output is correct |
18 | Correct | 1 ms | 1236 KB | Output is correct |
19 | Correct | 1 ms | 852 KB | Output is correct |
20 | Correct | 1 ms | 948 KB | Output is correct |
21 | Correct | 1 ms | 1236 KB | Output is correct |
22 | Correct | 1 ms | 724 KB | Output is correct |
23 | Correct | 1 ms | 1336 KB | Output is correct |
24 | Correct | 1 ms | 1108 KB | Output is correct |
25 | Correct | 1 ms | 1212 KB | Output is correct |
26 | Correct | 1 ms | 1236 KB | Output is correct |
27 | Correct | 1 ms | 596 KB | Output is correct |
28 | Correct | 1 ms | 692 KB | Output is correct |
29 | Correct | 1 ms | 1236 KB | Output is correct |
30 | Correct | 1 ms | 1236 KB | Output is correct |
31 | Correct | 1 ms | 1236 KB | Output is correct |
32 | Correct | 1 ms | 1108 KB | Output is correct |
33 | Correct | 1 ms | 1236 KB | Output is correct |
34 | Correct | 1 ms | 1236 KB | Output is correct |
35 | Correct | 1 ms | 1236 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | Output is correct |
2 | Correct | 1 ms | 436 KB | Output is correct |
3 | Correct | 1 ms | 724 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 596 KB | Output is correct |
6 | Correct | 1 ms | 980 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 1 ms | 828 KB | Output is correct |
9 | Correct | 1 ms | 980 KB | Output is correct |
10 | Correct | 1 ms | 308 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 980 KB | Output is correct |
13 | Correct | 1 ms | 980 KB | Output is correct |
14 | Correct | 1 ms | 596 KB | Output is correct |
15 | Correct | 1 ms | 596 KB | Output is correct |
16 | Correct | 1 ms | 980 KB | Output is correct |
17 | Correct | 1 ms | 980 KB | Output is correct |
18 | Correct | 95 ms | 106908 KB | Output is correct |
19 | Correct | 45 ms | 65088 KB | Output is correct |
20 | Correct | 23 ms | 35044 KB | Output is correct |
21 | Correct | 40 ms | 61544 KB | Output is correct |
22 | Correct | 54 ms | 79540 KB | Output is correct |
23 | Correct | 19 ms | 29908 KB | Output is correct |
24 | Correct | 17 ms | 23488 KB | Output is correct |
25 | Correct | 20 ms | 29236 KB | Output is correct |
26 | Correct | 7 ms | 11488 KB | Output is correct |
27 | Correct | 21 ms | 30544 KB | Output is correct |
28 | Correct | 14 ms | 21844 KB | Output is correct |
29 | Correct | 20 ms | 31180 KB | Output is correct |
30 | Correct | 14 ms | 24668 KB | Output is correct |
31 | Correct | 21 ms | 29292 KB | Output is correct |
32 | Correct | 11 ms | 15572 KB | Output is correct |
33 | Correct | 19 ms | 29268 KB | Output is correct |
34 | Correct | 8 ms | 10708 KB | Output is correct |
35 | Correct | 21 ms | 28600 KB | Output is correct |
36 | Correct | 8 ms | 13780 KB | Output is correct |
37 | Correct | 20 ms | 30548 KB | Output is correct |
38 | Correct | 12 ms | 16896 KB | Output is correct |
39 | Correct | 21 ms | 31748 KB | Output is correct |
40 | Correct | 11 ms | 18744 KB | Output is correct |
41 | Correct | 100 ms | 131540 KB | Output is correct |
42 | Correct | 83 ms | 88856 KB | Output is correct |
43 | Correct | 113 ms | 131544 KB | Output is correct |
44 | Correct | 63 ms | 87740 KB | Output is correct |
45 | Correct | 106 ms | 131544 KB | Output is correct |
46 | Correct | 89 ms | 88920 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | Output is correct |
2 | Correct | 1 ms | 436 KB | Output is correct |
3 | Correct | 1 ms | 724 KB | Output is correct |
4 | Correct | 1 ms | 468 KB | Output is correct |
5 | Correct | 1 ms | 596 KB | Output is correct |
6 | Correct | 1 ms | 980 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 1 ms | 828 KB | Output is correct |
9 | Correct | 1 ms | 980 KB | Output is correct |
10 | Correct | 1 ms | 308 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 980 KB | Output is correct |
13 | Correct | 1 ms | 980 KB | Output is correct |
14 | Correct | 1 ms | 596 KB | Output is correct |
15 | Correct | 1 ms | 596 KB | Output is correct |
16 | Correct | 1 ms | 980 KB | Output is correct |
17 | Correct | 1 ms | 980 KB | Output is correct |
18 | Correct | 1 ms | 1236 KB | Output is correct |
19 | Correct | 1 ms | 852 KB | Output is correct |
20 | Correct | 1 ms | 948 KB | Output is correct |
21 | Correct | 1 ms | 1236 KB | Output is correct |
22 | Correct | 1 ms | 724 KB | Output is correct |
23 | Correct | 1 ms | 1336 KB | Output is correct |
24 | Correct | 1 ms | 1108 KB | Output is correct |
25 | Correct | 1 ms | 1212 KB | Output is correct |
26 | Correct | 1 ms | 1236 KB | Output is correct |
27 | Correct | 1 ms | 596 KB | Output is correct |
28 | Correct | 1 ms | 692 KB | Output is correct |
29 | Correct | 1 ms | 1236 KB | Output is correct |
30 | Correct | 1 ms | 1236 KB | Output is correct |
31 | Correct | 1 ms | 1236 KB | Output is correct |
32 | Correct | 1 ms | 1108 KB | Output is correct |
33 | Correct | 1 ms | 1236 KB | Output is correct |
34 | Correct | 1 ms | 1236 KB | Output is correct |
35 | Correct | 1 ms | 1236 KB | Output is correct |
36 | Correct | 95 ms | 106908 KB | Output is correct |
37 | Correct | 45 ms | 65088 KB | Output is correct |
38 | Correct | 23 ms | 35044 KB | Output is correct |
39 | Correct | 40 ms | 61544 KB | Output is correct |
40 | Correct | 54 ms | 79540 KB | Output is correct |
41 | Correct | 19 ms | 29908 KB | Output is correct |
42 | Correct | 17 ms | 23488 KB | Output is correct |
43 | Correct | 20 ms | 29236 KB | Output is correct |
44 | Correct | 7 ms | 11488 KB | Output is correct |
45 | Correct | 21 ms | 30544 KB | Output is correct |
46 | Correct | 14 ms | 21844 KB | Output is correct |
47 | Correct | 20 ms | 31180 KB | Output is correct |
48 | Correct | 14 ms | 24668 KB | Output is correct |
49 | Correct | 21 ms | 29292 KB | Output is correct |
50 | Correct | 11 ms | 15572 KB | Output is correct |
51 | Correct | 19 ms | 29268 KB | Output is correct |
52 | Correct | 8 ms | 10708 KB | Output is correct |
53 | Correct | 21 ms | 28600 KB | Output is correct |
54 | Correct | 8 ms | 13780 KB | Output is correct |
55 | Correct | 20 ms | 30548 KB | Output is correct |
56 | Correct | 12 ms | 16896 KB | Output is correct |
57 | Correct | 21 ms | 31748 KB | Output is correct |
58 | Correct | 11 ms | 18744 KB | Output is correct |
59 | Correct | 100 ms | 131540 KB | Output is correct |
60 | Correct | 83 ms | 88856 KB | Output is correct |
61 | Correct | 113 ms | 131544 KB | Output is correct |
62 | Correct | 63 ms | 87740 KB | Output is correct |
63 | Correct | 106 ms | 131544 KB | Output is correct |
64 | Correct | 89 ms | 88920 KB | Output is correct |
65 | Correct | 91 ms | 118860 KB | Output is correct |
66 | Correct | 87 ms | 109200 KB | Output is correct |
67 | Correct | 80 ms | 104396 KB | Output is correct |
68 | Correct | 83 ms | 96556 KB | Output is correct |
69 | Correct | 93 ms | 117552 KB | Output is correct |
70 | Correct | 85 ms | 112684 KB | Output is correct |
71 | Correct | 82 ms | 113912 KB | Output is correct |
72 | Correct | 91 ms | 115188 KB | Output is correct |
73 | Correct | 83 ms | 106756 KB | Output is correct |
74 | Correct | 85 ms | 99820 KB | Output is correct |
75 | Correct | 82 ms | 110380 KB | Output is correct |
76 | Correct | 95 ms | 126404 KB | Output is correct |
77 | Correct | 99 ms | 126396 KB | Output is correct |
78 | Correct | 82 ms | 97676 KB | Output is correct |
79 | Correct | 78 ms | 101000 KB | Output is correct |
80 | Correct | 94 ms | 123860 KB | Output is correct |
81 | Correct | 78 ms | 102248 KB | Output is correct |
82 | Correct | 100 ms | 108048 KB | Output is correct |
83 | Correct | 108 ms | 131468 KB | Output is correct |
84 | Correct | 83 ms | 112772 KB | Output is correct |
85 | Correct | 92 ms | 122624 KB | Output is correct |
86 | Correct | 112 ms | 120148 KB | Output is correct |
87 | Correct | 95 ms | 110428 KB | Output is correct |
88 | Correct | 122 ms | 132784 KB | Output is correct |
89 | Correct | 107 ms | 132852 KB | Output is correct |
90 | Correct | 89 ms | 111572 KB | Output is correct |
91 | Correct | 124 ms | 132760 KB | Output is correct |
92 | Correct | 126 ms | 132852 KB | Output is correct |
93 | Correct | 110 ms | 130244 KB | Output is correct |