# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
438887 | 2021-06-28T22:40:17 Z | Snowfall | Collecting Stamps 3 (JOI20_ho_t3) | C++14 | 131 ms | 130744 KB |
#include<bits/stdc++.h> using namespace std; long long arr[205][205][205][2]; int a[205],b[205]; main() { int t,p; scanf("%d%d",&t,&p); queue<pair<int,pair<int,int> > >q; for(int i = 1;i <= t;i++) { scanf("%d",&a[i]); } for(int i = 1;i <= t;i++) { scanf("%d",&b[i]); } for(int i = 0;i <= t;i++) { for(int j = 0;j <= t;j++) { for(int k = 0;k <= t;k++) { for(int l = 0;l < 2;l++) arr[i][j][k][l]=1e18; } } } a[t+1]=p; arr[0][0][0][0]=0; arr[0][0][0][1]=0; for(int i = 0;i <= t;i++) { for(int j = 0;j+i <= t;j++) { for(int k = 0;k <= i+j;k++) { if(i+j+1<=t) { if(arr[i][j][k][0]+a[i+1]-a[i]<=b[i+1]) { arr[i+1][j][k+1][0]=min(arr[i+1][j][k+1][0],arr[i][j][k][0]+a[i+1]-a[i]); } else { arr[i+1][j][k][0]=min(arr[i+1][j][k][0],arr[i][j][k][0]+a[i+1]-a[i]); } if(arr[i][j][k][1]+a[t-j+1]-a[t-j]<=b[t-j]) { arr[i][j+1][k+1][1]=min(arr[i][j+1][k+1][1],arr[i][j][k][1]+a[t-j+1]-a[t-j]); } else { arr[i][j+1][k][1]=min(arr[i][j+1][k][1],arr[i][j][k][1]+a[t-j+1]-a[t-j]); } if(arr[i][j][k][0]+a[i]+p-a[t-j]<=b[t-j]) { arr[i][j+1][k+1][1]=min(arr[i][j+1][k+1][1],arr[i][j][k][0]+a[i]+p-a[t-j]); } else { arr[i][j+1][k][1]=min(arr[i][j+1][k][1],arr[i][j][k][0]+a[i]+p-a[t-j]); } if(arr[i][j][k][1]+p-a[t-j+1]+a[i+1]<=b[i+1]) { arr[i+1][j][k+1][0]=min(arr[i+1][j][k+1][0],arr[i][j][k][1]+p-a[t-j+1]+a[i+1]); } else { arr[i+1][j][k][0]=min(arr[i+1][j][k][0],arr[i][j][k][1]+p-a[t-j+1]+a[i+1]); } } } } } int mx=0; for(int i = 0;i <= t;i++) { for(int j = 0;j+i <= t;j++) { for(int k = 0;k <= i+j;k++) { for(int l = 0;l < 2;l++) { if(arr[i][j][k][l]!=1e18) mx=max(mx,k); } } } } printf("%d",mx); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 588 KB | Output is correct |
4 | Correct | 1 ms | 460 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 844 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 588 KB | Output is correct |
9 | Correct | 1 ms | 844 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 844 KB | Output is correct |
13 | Correct | 1 ms | 844 KB | Output is correct |
14 | Correct | 1 ms | 460 KB | Output is correct |
15 | Correct | 1 ms | 460 KB | Output is correct |
16 | Correct | 1 ms | 844 KB | Output is correct |
17 | Correct | 1 ms | 844 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 588 KB | Output is correct |
4 | Correct | 1 ms | 460 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 844 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 588 KB | Output is correct |
9 | Correct | 1 ms | 844 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 844 KB | Output is correct |
13 | Correct | 1 ms | 844 KB | Output is correct |
14 | Correct | 1 ms | 460 KB | Output is correct |
15 | Correct | 1 ms | 460 KB | Output is correct |
16 | Correct | 1 ms | 844 KB | Output is correct |
17 | Correct | 1 ms | 844 KB | Output is correct |
18 | Correct | 2 ms | 972 KB | Output is correct |
19 | Correct | 1 ms | 588 KB | Output is correct |
20 | Correct | 1 ms | 844 KB | Output is correct |
21 | Correct | 1 ms | 972 KB | Output is correct |
22 | Correct | 1 ms | 588 KB | Output is correct |
23 | Correct | 1 ms | 1100 KB | Output is correct |
24 | Correct | 1 ms | 844 KB | Output is correct |
25 | Correct | 1 ms | 972 KB | Output is correct |
26 | Correct | 1 ms | 972 KB | Output is correct |
27 | Correct | 1 ms | 460 KB | Output is correct |
28 | Correct | 1 ms | 588 KB | Output is correct |
29 | Correct | 1 ms | 1100 KB | Output is correct |
30 | Correct | 1 ms | 1100 KB | Output is correct |
31 | Correct | 1 ms | 972 KB | Output is correct |
32 | Correct | 1 ms | 844 KB | Output is correct |
33 | Correct | 1 ms | 1100 KB | Output is correct |
34 | Correct | 1 ms | 1100 KB | Output is correct |
35 | Correct | 1 ms | 1100 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 588 KB | Output is correct |
4 | Correct | 1 ms | 460 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 844 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 588 KB | Output is correct |
9 | Correct | 1 ms | 844 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 844 KB | Output is correct |
13 | Correct | 1 ms | 844 KB | Output is correct |
14 | Correct | 1 ms | 460 KB | Output is correct |
15 | Correct | 1 ms | 460 KB | Output is correct |
16 | Correct | 1 ms | 844 KB | Output is correct |
17 | Correct | 1 ms | 844 KB | Output is correct |
18 | Correct | 88 ms | 104936 KB | Output is correct |
19 | Correct | 55 ms | 63612 KB | Output is correct |
20 | Correct | 27 ms | 33996 KB | Output is correct |
21 | Correct | 50 ms | 60092 KB | Output is correct |
22 | Correct | 70 ms | 77932 KB | Output is correct |
23 | Correct | 21 ms | 28904 KB | Output is correct |
24 | Correct | 17 ms | 22604 KB | Output is correct |
25 | Correct | 20 ms | 28236 KB | Output is correct |
26 | Correct | 7 ms | 10856 KB | Output is correct |
27 | Correct | 25 ms | 29540 KB | Output is correct |
28 | Correct | 14 ms | 21024 KB | Output is correct |
29 | Correct | 21 ms | 30072 KB | Output is correct |
30 | Correct | 16 ms | 23628 KB | Output is correct |
31 | Correct | 20 ms | 28276 KB | Output is correct |
32 | Correct | 10 ms | 14848 KB | Output is correct |
33 | Correct | 21 ms | 28332 KB | Output is correct |
34 | Correct | 7 ms | 10060 KB | Output is correct |
35 | Correct | 19 ms | 27724 KB | Output is correct |
36 | Correct | 8 ms | 13132 KB | Output is correct |
37 | Correct | 21 ms | 29544 KB | Output is correct |
38 | Correct | 12 ms | 16212 KB | Output is correct |
39 | Correct | 24 ms | 30784 KB | Output is correct |
40 | Correct | 13 ms | 17996 KB | Output is correct |
41 | Correct | 116 ms | 129444 KB | Output is correct |
42 | Correct | 75 ms | 87236 KB | Output is correct |
43 | Correct | 131 ms | 129376 KB | Output is correct |
44 | Correct | 75 ms | 86160 KB | Output is correct |
45 | Correct | 115 ms | 129348 KB | Output is correct |
46 | Correct | 71 ms | 87192 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 588 KB | Output is correct |
4 | Correct | 1 ms | 460 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 844 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 588 KB | Output is correct |
9 | Correct | 1 ms | 844 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 1 ms | 844 KB | Output is correct |
13 | Correct | 1 ms | 844 KB | Output is correct |
14 | Correct | 1 ms | 460 KB | Output is correct |
15 | Correct | 1 ms | 460 KB | Output is correct |
16 | Correct | 1 ms | 844 KB | Output is correct |
17 | Correct | 1 ms | 844 KB | Output is correct |
18 | Correct | 2 ms | 972 KB | Output is correct |
19 | Correct | 1 ms | 588 KB | Output is correct |
20 | Correct | 1 ms | 844 KB | Output is correct |
21 | Correct | 1 ms | 972 KB | Output is correct |
22 | Correct | 1 ms | 588 KB | Output is correct |
23 | Correct | 1 ms | 1100 KB | Output is correct |
24 | Correct | 1 ms | 844 KB | Output is correct |
25 | Correct | 1 ms | 972 KB | Output is correct |
26 | Correct | 1 ms | 972 KB | Output is correct |
27 | Correct | 1 ms | 460 KB | Output is correct |
28 | Correct | 1 ms | 588 KB | Output is correct |
29 | Correct | 1 ms | 1100 KB | Output is correct |
30 | Correct | 1 ms | 1100 KB | Output is correct |
31 | Correct | 1 ms | 972 KB | Output is correct |
32 | Correct | 1 ms | 844 KB | Output is correct |
33 | Correct | 1 ms | 1100 KB | Output is correct |
34 | Correct | 1 ms | 1100 KB | Output is correct |
35 | Correct | 1 ms | 1100 KB | Output is correct |
36 | Correct | 88 ms | 104936 KB | Output is correct |
37 | Correct | 55 ms | 63612 KB | Output is correct |
38 | Correct | 27 ms | 33996 KB | Output is correct |
39 | Correct | 50 ms | 60092 KB | Output is correct |
40 | Correct | 70 ms | 77932 KB | Output is correct |
41 | Correct | 21 ms | 28904 KB | Output is correct |
42 | Correct | 17 ms | 22604 KB | Output is correct |
43 | Correct | 20 ms | 28236 KB | Output is correct |
44 | Correct | 7 ms | 10856 KB | Output is correct |
45 | Correct | 25 ms | 29540 KB | Output is correct |
46 | Correct | 14 ms | 21024 KB | Output is correct |
47 | Correct | 21 ms | 30072 KB | Output is correct |
48 | Correct | 16 ms | 23628 KB | Output is correct |
49 | Correct | 20 ms | 28276 KB | Output is correct |
50 | Correct | 10 ms | 14848 KB | Output is correct |
51 | Correct | 21 ms | 28332 KB | Output is correct |
52 | Correct | 7 ms | 10060 KB | Output is correct |
53 | Correct | 19 ms | 27724 KB | Output is correct |
54 | Correct | 8 ms | 13132 KB | Output is correct |
55 | Correct | 21 ms | 29544 KB | Output is correct |
56 | Correct | 12 ms | 16212 KB | Output is correct |
57 | Correct | 24 ms | 30784 KB | Output is correct |
58 | Correct | 13 ms | 17996 KB | Output is correct |
59 | Correct | 116 ms | 129444 KB | Output is correct |
60 | Correct | 75 ms | 87236 KB | Output is correct |
61 | Correct | 131 ms | 129376 KB | Output is correct |
62 | Correct | 75 ms | 86160 KB | Output is correct |
63 | Correct | 115 ms | 129348 KB | Output is correct |
64 | Correct | 71 ms | 87192 KB | Output is correct |
65 | Correct | 98 ms | 116924 KB | Output is correct |
66 | Correct | 92 ms | 107204 KB | Output is correct |
67 | Correct | 92 ms | 102552 KB | Output is correct |
68 | Correct | 75 ms | 94712 KB | Output is correct |
69 | Correct | 103 ms | 115548 KB | Output is correct |
70 | Correct | 93 ms | 110884 KB | Output is correct |
71 | Correct | 91 ms | 111996 KB | Output is correct |
72 | Correct | 95 ms | 113348 KB | Output is correct |
73 | Correct | 89 ms | 104884 KB | Output is correct |
74 | Correct | 85 ms | 97988 KB | Output is correct |
75 | Correct | 96 ms | 108360 KB | Output is correct |
76 | Correct | 114 ms | 124284 KB | Output is correct |
77 | Correct | 113 ms | 124340 KB | Output is correct |
78 | Correct | 86 ms | 95852 KB | Output is correct |
79 | Correct | 80 ms | 99208 KB | Output is correct |
80 | Correct | 101 ms | 121820 KB | Output is correct |
81 | Correct | 92 ms | 100296 KB | Output is correct |
82 | Correct | 87 ms | 105980 KB | Output is correct |
83 | Correct | 109 ms | 129348 KB | Output is correct |
84 | Correct | 85 ms | 110788 KB | Output is correct |
85 | Correct | 100 ms | 120524 KB | Output is correct |
86 | Correct | 106 ms | 118000 KB | Output is correct |
87 | Correct | 106 ms | 108400 KB | Output is correct |
88 | Correct | 110 ms | 130680 KB | Output is correct |
89 | Correct | 117 ms | 130728 KB | Output is correct |
90 | Correct | 99 ms | 109620 KB | Output is correct |
91 | Correct | 118 ms | 130744 KB | Output is correct |
92 | Correct | 109 ms | 130648 KB | Output is correct |
93 | Correct | 115 ms | 128196 KB | Output is correct |