# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
226465 | 2020-04-23T21:49:26 Z | thebes | Collecting Stamps 3 (JOI20_ho_t3) | C++14 | 236 ms | 134988 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; const int MN = 202; int N, L, i, arr[MN], t[MN]; ll nxt, d, td, k, dis[2][MN][MN][MN]; struct idk{int l, r, k, p;}; bitset<MN> vs[2][MN][MN], st[2][MN][MN]; queue<idk> q; int main(){ for(scanf("%d%d",&N,&L),i=1;i<=N;i++) scanf("%d",&arr[i]); for(i=1;i<=N;i++) scanf("%d",&t[i]); arr[0]=0; t[0]=-1; q.push({0,0,0,0}); memset(dis,0x3f,sizeof(dis)); dis[0][0][0][0]=0; while(q.size()){ idk cur=q.front(); q.pop(); vs[cur.p][cur.l][cur.r][cur.k]=1; st[cur.p][cur.l][cur.r][cur.k]=0; ll T = dis[cur.p][cur.l][cur.r][cur.k]; if((cur.r+1)%(N+1)==cur.l%(N+1)){ continue; // cannot expand further } nxt=cur.r+1; if(nxt>N) nxt=0; d=arr[nxt]-arr[cur.r]; if(d<0) d+=L; if(!cur.p) td=arr[cur.r]-arr[cur.l]; else td=0; if(td<0) td+=L; d+=td; if(T+d<=t[nxt]) k=cur.k+1; else k=cur.k; if(T+d<dis[1][cur.l][nxt][k]){ dis[1][cur.l][nxt][k]=T+d; if(!st[1][cur.l][nxt][k]){ q.push({cur.l,nxt,k,1}); st[1][cur.l][nxt][k]=1; } } nxt=cur.l-1; if(nxt<0) nxt=N; d=arr[cur.l]-arr[nxt]; if(d<0) d+=L; if(cur.p) td=arr[cur.r]-arr[cur.l]; else td=0; if(td<0) td+=L; d+=td; if(T+d<=t[nxt]) k=cur.k+1; else k=cur.k; if(T+d<dis[0][nxt][cur.r][k]){ dis[0][nxt][cur.r][k]=T+d; if(!st[0][nxt][cur.r][k]){ q.push({nxt,cur.r,k,0}); st[0][nxt][cur.r][k]=1; } } } int ans=0; for(i=0;i<=N;i++){ for(int j=0;j<=N;j++){ for(int k=0;k<=N;k++){ if(dis[0][i][j][k]<(1LL<<60)||dis[1][i][j][k]<(1LL<<60)) ans=max(ans,k); } } } printf("%d\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 75 ms | 129400 KB | Output is correct |
2 | Correct | 63 ms | 129272 KB | Output is correct |
3 | Correct | 66 ms | 129660 KB | Output is correct |
4 | Correct | 72 ms | 129528 KB | Output is correct |
5 | Correct | 65 ms | 129528 KB | Output is correct |
6 | Correct | 67 ms | 129656 KB | Output is correct |
7 | Correct | 65 ms | 129528 KB | Output is correct |
8 | Correct | 70 ms | 129528 KB | Output is correct |
9 | Correct | 73 ms | 129656 KB | Output is correct |
10 | Correct | 64 ms | 129400 KB | Output is correct |
11 | Correct | 65 ms | 129488 KB | Output is correct |
12 | Correct | 66 ms | 129656 KB | Output is correct |
13 | Correct | 72 ms | 129656 KB | Output is correct |
14 | Correct | 63 ms | 129528 KB | Output is correct |
15 | Correct | 63 ms | 129528 KB | Output is correct |
16 | Correct | 64 ms | 129528 KB | Output is correct |
17 | Correct | 73 ms | 129532 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 75 ms | 129400 KB | Output is correct |
2 | Correct | 63 ms | 129272 KB | Output is correct |
3 | Correct | 66 ms | 129660 KB | Output is correct |
4 | Correct | 72 ms | 129528 KB | Output is correct |
5 | Correct | 65 ms | 129528 KB | Output is correct |
6 | Correct | 67 ms | 129656 KB | Output is correct |
7 | Correct | 65 ms | 129528 KB | Output is correct |
8 | Correct | 70 ms | 129528 KB | Output is correct |
9 | Correct | 73 ms | 129656 KB | Output is correct |
10 | Correct | 64 ms | 129400 KB | Output is correct |
11 | Correct | 65 ms | 129488 KB | Output is correct |
12 | Correct | 66 ms | 129656 KB | Output is correct |
13 | Correct | 72 ms | 129656 KB | Output is correct |
14 | Correct | 63 ms | 129528 KB | Output is correct |
15 | Correct | 63 ms | 129528 KB | Output is correct |
16 | Correct | 64 ms | 129528 KB | Output is correct |
17 | Correct | 73 ms | 129532 KB | Output is correct |
18 | Correct | 70 ms | 129556 KB | Output is correct |
19 | Correct | 73 ms | 129528 KB | Output is correct |
20 | Correct | 64 ms | 129528 KB | Output is correct |
21 | Correct | 64 ms | 129656 KB | Output is correct |
22 | Correct | 64 ms | 129528 KB | Output is correct |
23 | Correct | 73 ms | 129656 KB | Output is correct |
24 | Correct | 67 ms | 129528 KB | Output is correct |
25 | Correct | 65 ms | 129656 KB | Output is correct |
26 | Correct | 63 ms | 129656 KB | Output is correct |
27 | Correct | 65 ms | 129528 KB | Output is correct |
28 | Correct | 64 ms | 129528 KB | Output is correct |
29 | Correct | 72 ms | 129656 KB | Output is correct |
30 | Correct | 74 ms | 129656 KB | Output is correct |
31 | Correct | 71 ms | 129656 KB | Output is correct |
32 | Correct | 64 ms | 129528 KB | Output is correct |
33 | Correct | 72 ms | 129656 KB | Output is correct |
34 | Correct | 65 ms | 129656 KB | Output is correct |
35 | Correct | 66 ms | 129656 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 75 ms | 129400 KB | Output is correct |
2 | Correct | 63 ms | 129272 KB | Output is correct |
3 | Correct | 66 ms | 129660 KB | Output is correct |
4 | Correct | 72 ms | 129528 KB | Output is correct |
5 | Correct | 65 ms | 129528 KB | Output is correct |
6 | Correct | 67 ms | 129656 KB | Output is correct |
7 | Correct | 65 ms | 129528 KB | Output is correct |
8 | Correct | 70 ms | 129528 KB | Output is correct |
9 | Correct | 73 ms | 129656 KB | Output is correct |
10 | Correct | 64 ms | 129400 KB | Output is correct |
11 | Correct | 65 ms | 129488 KB | Output is correct |
12 | Correct | 66 ms | 129656 KB | Output is correct |
13 | Correct | 72 ms | 129656 KB | Output is correct |
14 | Correct | 63 ms | 129528 KB | Output is correct |
15 | Correct | 63 ms | 129528 KB | Output is correct |
16 | Correct | 64 ms | 129528 KB | Output is correct |
17 | Correct | 73 ms | 129532 KB | Output is correct |
18 | Correct | 137 ms | 134008 KB | Output is correct |
19 | Correct | 103 ms | 132856 KB | Output is correct |
20 | Correct | 79 ms | 131704 KB | Output is correct |
21 | Correct | 98 ms | 132600 KB | Output is correct |
22 | Correct | 129 ms | 133368 KB | Output is correct |
23 | Correct | 82 ms | 131576 KB | Output is correct |
24 | Correct | 82 ms | 131192 KB | Output is correct |
25 | Correct | 94 ms | 131580 KB | Output is correct |
26 | Correct | 75 ms | 130448 KB | Output is correct |
27 | Correct | 84 ms | 131576 KB | Output is correct |
28 | Correct | 80 ms | 131064 KB | Output is correct |
29 | Correct | 79 ms | 131704 KB | Output is correct |
30 | Correct | 71 ms | 131192 KB | Output is correct |
31 | Correct | 79 ms | 131576 KB | Output is correct |
32 | Correct | 70 ms | 130808 KB | Output is correct |
33 | Correct | 84 ms | 131448 KB | Output is correct |
34 | Correct | 66 ms | 130424 KB | Output is correct |
35 | Correct | 80 ms | 131320 KB | Output is correct |
36 | Correct | 75 ms | 130680 KB | Output is correct |
37 | Correct | 70 ms | 131448 KB | Output is correct |
38 | Correct | 69 ms | 130808 KB | Output is correct |
39 | Correct | 73 ms | 131448 KB | Output is correct |
40 | Correct | 72 ms | 130944 KB | Output is correct |
41 | Correct | 173 ms | 134776 KB | Output is correct |
42 | Correct | 75 ms | 133240 KB | Output is correct |
43 | Correct | 198 ms | 134776 KB | Output is correct |
44 | Correct | 73 ms | 133112 KB | Output is correct |
45 | Correct | 172 ms | 134648 KB | Output is correct |
46 | Correct | 78 ms | 133244 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 75 ms | 129400 KB | Output is correct |
2 | Correct | 63 ms | 129272 KB | Output is correct |
3 | Correct | 66 ms | 129660 KB | Output is correct |
4 | Correct | 72 ms | 129528 KB | Output is correct |
5 | Correct | 65 ms | 129528 KB | Output is correct |
6 | Correct | 67 ms | 129656 KB | Output is correct |
7 | Correct | 65 ms | 129528 KB | Output is correct |
8 | Correct | 70 ms | 129528 KB | Output is correct |
9 | Correct | 73 ms | 129656 KB | Output is correct |
10 | Correct | 64 ms | 129400 KB | Output is correct |
11 | Correct | 65 ms | 129488 KB | Output is correct |
12 | Correct | 66 ms | 129656 KB | Output is correct |
13 | Correct | 72 ms | 129656 KB | Output is correct |
14 | Correct | 63 ms | 129528 KB | Output is correct |
15 | Correct | 63 ms | 129528 KB | Output is correct |
16 | Correct | 64 ms | 129528 KB | Output is correct |
17 | Correct | 73 ms | 129532 KB | Output is correct |
18 | Correct | 70 ms | 129556 KB | Output is correct |
19 | Correct | 73 ms | 129528 KB | Output is correct |
20 | Correct | 64 ms | 129528 KB | Output is correct |
21 | Correct | 64 ms | 129656 KB | Output is correct |
22 | Correct | 64 ms | 129528 KB | Output is correct |
23 | Correct | 73 ms | 129656 KB | Output is correct |
24 | Correct | 67 ms | 129528 KB | Output is correct |
25 | Correct | 65 ms | 129656 KB | Output is correct |
26 | Correct | 63 ms | 129656 KB | Output is correct |
27 | Correct | 65 ms | 129528 KB | Output is correct |
28 | Correct | 64 ms | 129528 KB | Output is correct |
29 | Correct | 72 ms | 129656 KB | Output is correct |
30 | Correct | 74 ms | 129656 KB | Output is correct |
31 | Correct | 71 ms | 129656 KB | Output is correct |
32 | Correct | 64 ms | 129528 KB | Output is correct |
33 | Correct | 72 ms | 129656 KB | Output is correct |
34 | Correct | 65 ms | 129656 KB | Output is correct |
35 | Correct | 66 ms | 129656 KB | Output is correct |
36 | Correct | 137 ms | 134008 KB | Output is correct |
37 | Correct | 103 ms | 132856 KB | Output is correct |
38 | Correct | 79 ms | 131704 KB | Output is correct |
39 | Correct | 98 ms | 132600 KB | Output is correct |
40 | Correct | 129 ms | 133368 KB | Output is correct |
41 | Correct | 82 ms | 131576 KB | Output is correct |
42 | Correct | 82 ms | 131192 KB | Output is correct |
43 | Correct | 94 ms | 131580 KB | Output is correct |
44 | Correct | 75 ms | 130448 KB | Output is correct |
45 | Correct | 84 ms | 131576 KB | Output is correct |
46 | Correct | 80 ms | 131064 KB | Output is correct |
47 | Correct | 79 ms | 131704 KB | Output is correct |
48 | Correct | 71 ms | 131192 KB | Output is correct |
49 | Correct | 79 ms | 131576 KB | Output is correct |
50 | Correct | 70 ms | 130808 KB | Output is correct |
51 | Correct | 84 ms | 131448 KB | Output is correct |
52 | Correct | 66 ms | 130424 KB | Output is correct |
53 | Correct | 80 ms | 131320 KB | Output is correct |
54 | Correct | 75 ms | 130680 KB | Output is correct |
55 | Correct | 70 ms | 131448 KB | Output is correct |
56 | Correct | 69 ms | 130808 KB | Output is correct |
57 | Correct | 73 ms | 131448 KB | Output is correct |
58 | Correct | 72 ms | 130944 KB | Output is correct |
59 | Correct | 173 ms | 134776 KB | Output is correct |
60 | Correct | 75 ms | 133240 KB | Output is correct |
61 | Correct | 198 ms | 134776 KB | Output is correct |
62 | Correct | 73 ms | 133112 KB | Output is correct |
63 | Correct | 172 ms | 134648 KB | Output is correct |
64 | Correct | 78 ms | 133244 KB | Output is correct |
65 | Correct | 159 ms | 134320 KB | Output is correct |
66 | Correct | 143 ms | 134136 KB | Output is correct |
67 | Correct | 136 ms | 133880 KB | Output is correct |
68 | Correct | 131 ms | 133804 KB | Output is correct |
69 | Correct | 160 ms | 134264 KB | Output is correct |
70 | Correct | 168 ms | 134512 KB | Output is correct |
71 | Correct | 149 ms | 134264 KB | Output is correct |
72 | Correct | 170 ms | 134520 KB | Output is correct |
73 | Correct | 115 ms | 134020 KB | Output is correct |
74 | Correct | 172 ms | 134136 KB | Output is correct |
75 | Correct | 164 ms | 134008 KB | Output is correct |
76 | Correct | 201 ms | 134648 KB | Output is correct |
77 | Correct | 168 ms | 134392 KB | Output is correct |
78 | Correct | 155 ms | 134008 KB | Output is correct |
79 | Correct | 164 ms | 133880 KB | Output is correct |
80 | Correct | 198 ms | 134520 KB | Output is correct |
81 | Correct | 155 ms | 133752 KB | Output is correct |
82 | Correct | 112 ms | 133880 KB | Output is correct |
83 | Correct | 176 ms | 134520 KB | Output is correct |
84 | Correct | 114 ms | 133880 KB | Output is correct |
85 | Correct | 151 ms | 134232 KB | Output is correct |
86 | Correct | 144 ms | 134136 KB | Output is correct |
87 | Correct | 149 ms | 134172 KB | Output is correct |
88 | Correct | 236 ms | 134904 KB | Output is correct |
89 | Correct | 176 ms | 134716 KB | Output is correct |
90 | Correct | 76 ms | 133624 KB | Output is correct |
91 | Correct | 209 ms | 134988 KB | Output is correct |
92 | Correct | 172 ms | 134648 KB | Output is correct |
93 | Correct | 80 ms | 134136 KB | Output is correct |