# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
698628 | 2023-02-14T05:57:36 Z | Baytoro | Collecting Stamps 3 (JOI20_ho_t3) | C++17 | 196 ms | 135292 KB |
#include <bits/stdc++.h> using namespace std; #define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fr first #define sc second #define endl '\n' #define int long long #define ll long long void fopn(string name){ freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } const ll INF=1e18,mod=1e9+7; const int N=205; int dp[N][N][N][2],x[N],t[N],n,L; void solve(){ cin>>n>>L; for(int i=1;i<=n;i++) cin>>x[i]; for(int i=1;i<=n;i++) cin>>t[i]; memset(dp,0x3f3f3f3f,sizeof(dp)); int S=dp[0][0][0][0]; dp[0][0][0][0]=dp[0][0][0][1]=0; for(int i=0;i<n;i++){ for(int l=0;l<=n;l++){ for(int r=0;r<=n;r++){ if(l+r>=n) continue; for(int k=0;k<2;k++){ int a=dp[i][l][r][k]; if(k==0) a+=(x[l+1]-x[l]); else a+=(L-x[n+1-r]+x[l+1]); dp[i+(a<=t[l+1])][l+1][r][0]=min(dp[i+(a<=t[l+1])][l+1][r][0],a); a=dp[i][l][r][k]; if(k==1) a+=(x[n+1-r]-x[n-r]+L)%L; else a+=(x[l]+L-x[n-r]); dp[i+(a<=t[n-r])][l][r+1][1]=min(dp[i+(a<=t[n-r])][l][r+1][1],a); } } } } int ans=0; for(int i=1;i<=n;i++){ for(int l=0;l<=n;l++) for(int r=0;r<=n;r++) if(dp[i][l][r][0]!=S || dp[i][l][r][1]!=S) ans=i; } cout<<ans; } main(){ ios; int T=1; //cin>>T; while(T--){ solve(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 135084 KB | Output is correct |
2 | Correct | 50 ms | 135184 KB | Output is correct |
3 | Correct | 49 ms | 135144 KB | Output is correct |
4 | Correct | 49 ms | 135068 KB | Output is correct |
5 | Correct | 49 ms | 135124 KB | Output is correct |
6 | Correct | 58 ms | 135116 KB | Output is correct |
7 | Correct | 50 ms | 135164 KB | Output is correct |
8 | Correct | 49 ms | 135116 KB | Output is correct |
9 | Correct | 52 ms | 135124 KB | Output is correct |
10 | Correct | 51 ms | 135124 KB | Output is correct |
11 | Correct | 51 ms | 135176 KB | Output is correct |
12 | Correct | 50 ms | 135116 KB | Output is correct |
13 | Correct | 52 ms | 135084 KB | Output is correct |
14 | Correct | 50 ms | 135116 KB | Output is correct |
15 | Correct | 56 ms | 135132 KB | Output is correct |
16 | Correct | 50 ms | 135128 KB | Output is correct |
17 | Correct | 53 ms | 135064 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 135084 KB | Output is correct |
2 | Correct | 50 ms | 135184 KB | Output is correct |
3 | Correct | 49 ms | 135144 KB | Output is correct |
4 | Correct | 49 ms | 135068 KB | Output is correct |
5 | Correct | 49 ms | 135124 KB | Output is correct |
6 | Correct | 58 ms | 135116 KB | Output is correct |
7 | Correct | 50 ms | 135164 KB | Output is correct |
8 | Correct | 49 ms | 135116 KB | Output is correct |
9 | Correct | 52 ms | 135124 KB | Output is correct |
10 | Correct | 51 ms | 135124 KB | Output is correct |
11 | Correct | 51 ms | 135176 KB | Output is correct |
12 | Correct | 50 ms | 135116 KB | Output is correct |
13 | Correct | 52 ms | 135084 KB | Output is correct |
14 | Correct | 50 ms | 135116 KB | Output is correct |
15 | Correct | 56 ms | 135132 KB | Output is correct |
16 | Correct | 50 ms | 135128 KB | Output is correct |
17 | Correct | 53 ms | 135064 KB | Output is correct |
18 | Correct | 54 ms | 135124 KB | Output is correct |
19 | Correct | 56 ms | 135116 KB | Output is correct |
20 | Correct | 52 ms | 135156 KB | Output is correct |
21 | Correct | 50 ms | 135112 KB | Output is correct |
22 | Correct | 50 ms | 135128 KB | Output is correct |
23 | Correct | 50 ms | 135116 KB | Output is correct |
24 | Correct | 52 ms | 135160 KB | Output is correct |
25 | Correct | 55 ms | 135176 KB | Output is correct |
26 | Correct | 51 ms | 135132 KB | Output is correct |
27 | Correct | 56 ms | 135068 KB | Output is correct |
28 | Correct | 53 ms | 135164 KB | Output is correct |
29 | Correct | 50 ms | 135116 KB | Output is correct |
30 | Correct | 49 ms | 135104 KB | Output is correct |
31 | Correct | 50 ms | 135084 KB | Output is correct |
32 | Correct | 53 ms | 135096 KB | Output is correct |
33 | Correct | 52 ms | 135116 KB | Output is correct |
34 | Correct | 58 ms | 135064 KB | Output is correct |
35 | Correct | 50 ms | 135080 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 135084 KB | Output is correct |
2 | Correct | 50 ms | 135184 KB | Output is correct |
3 | Correct | 49 ms | 135144 KB | Output is correct |
4 | Correct | 49 ms | 135068 KB | Output is correct |
5 | Correct | 49 ms | 135124 KB | Output is correct |
6 | Correct | 58 ms | 135116 KB | Output is correct |
7 | Correct | 50 ms | 135164 KB | Output is correct |
8 | Correct | 49 ms | 135116 KB | Output is correct |
9 | Correct | 52 ms | 135124 KB | Output is correct |
10 | Correct | 51 ms | 135124 KB | Output is correct |
11 | Correct | 51 ms | 135176 KB | Output is correct |
12 | Correct | 50 ms | 135116 KB | Output is correct |
13 | Correct | 52 ms | 135084 KB | Output is correct |
14 | Correct | 50 ms | 135116 KB | Output is correct |
15 | Correct | 56 ms | 135132 KB | Output is correct |
16 | Correct | 50 ms | 135128 KB | Output is correct |
17 | Correct | 53 ms | 135064 KB | Output is correct |
18 | Correct | 157 ms | 135176 KB | Output is correct |
19 | Correct | 91 ms | 135176 KB | Output is correct |
20 | Correct | 76 ms | 135180 KB | Output is correct |
21 | Correct | 94 ms | 135056 KB | Output is correct |
22 | Correct | 113 ms | 135168 KB | Output is correct |
23 | Correct | 65 ms | 135180 KB | Output is correct |
24 | Correct | 62 ms | 135208 KB | Output is correct |
25 | Correct | 67 ms | 135116 KB | Output is correct |
26 | Correct | 63 ms | 135176 KB | Output is correct |
27 | Correct | 74 ms | 135292 KB | Output is correct |
28 | Correct | 59 ms | 135136 KB | Output is correct |
29 | Correct | 66 ms | 135096 KB | Output is correct |
30 | Correct | 63 ms | 135076 KB | Output is correct |
31 | Correct | 68 ms | 135184 KB | Output is correct |
32 | Correct | 63 ms | 135116 KB | Output is correct |
33 | Correct | 65 ms | 135104 KB | Output is correct |
34 | Correct | 54 ms | 135080 KB | Output is correct |
35 | Correct | 72 ms | 135108 KB | Output is correct |
36 | Correct | 64 ms | 135184 KB | Output is correct |
37 | Correct | 67 ms | 135116 KB | Output is correct |
38 | Correct | 57 ms | 135168 KB | Output is correct |
39 | Correct | 68 ms | 135088 KB | Output is correct |
40 | Correct | 59 ms | 135184 KB | Output is correct |
41 | Correct | 186 ms | 135184 KB | Output is correct |
42 | Correct | 123 ms | 135180 KB | Output is correct |
43 | Correct | 183 ms | 135188 KB | Output is correct |
44 | Correct | 122 ms | 135232 KB | Output is correct |
45 | Correct | 191 ms | 135184 KB | Output is correct |
46 | Correct | 123 ms | 135116 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 135084 KB | Output is correct |
2 | Correct | 50 ms | 135184 KB | Output is correct |
3 | Correct | 49 ms | 135144 KB | Output is correct |
4 | Correct | 49 ms | 135068 KB | Output is correct |
5 | Correct | 49 ms | 135124 KB | Output is correct |
6 | Correct | 58 ms | 135116 KB | Output is correct |
7 | Correct | 50 ms | 135164 KB | Output is correct |
8 | Correct | 49 ms | 135116 KB | Output is correct |
9 | Correct | 52 ms | 135124 KB | Output is correct |
10 | Correct | 51 ms | 135124 KB | Output is correct |
11 | Correct | 51 ms | 135176 KB | Output is correct |
12 | Correct | 50 ms | 135116 KB | Output is correct |
13 | Correct | 52 ms | 135084 KB | Output is correct |
14 | Correct | 50 ms | 135116 KB | Output is correct |
15 | Correct | 56 ms | 135132 KB | Output is correct |
16 | Correct | 50 ms | 135128 KB | Output is correct |
17 | Correct | 53 ms | 135064 KB | Output is correct |
18 | Correct | 54 ms | 135124 KB | Output is correct |
19 | Correct | 56 ms | 135116 KB | Output is correct |
20 | Correct | 52 ms | 135156 KB | Output is correct |
21 | Correct | 50 ms | 135112 KB | Output is correct |
22 | Correct | 50 ms | 135128 KB | Output is correct |
23 | Correct | 50 ms | 135116 KB | Output is correct |
24 | Correct | 52 ms | 135160 KB | Output is correct |
25 | Correct | 55 ms | 135176 KB | Output is correct |
26 | Correct | 51 ms | 135132 KB | Output is correct |
27 | Correct | 56 ms | 135068 KB | Output is correct |
28 | Correct | 53 ms | 135164 KB | Output is correct |
29 | Correct | 50 ms | 135116 KB | Output is correct |
30 | Correct | 49 ms | 135104 KB | Output is correct |
31 | Correct | 50 ms | 135084 KB | Output is correct |
32 | Correct | 53 ms | 135096 KB | Output is correct |
33 | Correct | 52 ms | 135116 KB | Output is correct |
34 | Correct | 58 ms | 135064 KB | Output is correct |
35 | Correct | 50 ms | 135080 KB | Output is correct |
36 | Correct | 157 ms | 135176 KB | Output is correct |
37 | Correct | 91 ms | 135176 KB | Output is correct |
38 | Correct | 76 ms | 135180 KB | Output is correct |
39 | Correct | 94 ms | 135056 KB | Output is correct |
40 | Correct | 113 ms | 135168 KB | Output is correct |
41 | Correct | 65 ms | 135180 KB | Output is correct |
42 | Correct | 62 ms | 135208 KB | Output is correct |
43 | Correct | 67 ms | 135116 KB | Output is correct |
44 | Correct | 63 ms | 135176 KB | Output is correct |
45 | Correct | 74 ms | 135292 KB | Output is correct |
46 | Correct | 59 ms | 135136 KB | Output is correct |
47 | Correct | 66 ms | 135096 KB | Output is correct |
48 | Correct | 63 ms | 135076 KB | Output is correct |
49 | Correct | 68 ms | 135184 KB | Output is correct |
50 | Correct | 63 ms | 135116 KB | Output is correct |
51 | Correct | 65 ms | 135104 KB | Output is correct |
52 | Correct | 54 ms | 135080 KB | Output is correct |
53 | Correct | 72 ms | 135108 KB | Output is correct |
54 | Correct | 64 ms | 135184 KB | Output is correct |
55 | Correct | 67 ms | 135116 KB | Output is correct |
56 | Correct | 57 ms | 135168 KB | Output is correct |
57 | Correct | 68 ms | 135088 KB | Output is correct |
58 | Correct | 59 ms | 135184 KB | Output is correct |
59 | Correct | 186 ms | 135184 KB | Output is correct |
60 | Correct | 123 ms | 135180 KB | Output is correct |
61 | Correct | 183 ms | 135188 KB | Output is correct |
62 | Correct | 122 ms | 135232 KB | Output is correct |
63 | Correct | 191 ms | 135184 KB | Output is correct |
64 | Correct | 123 ms | 135116 KB | Output is correct |
65 | Correct | 164 ms | 135188 KB | Output is correct |
66 | Correct | 141 ms | 135124 KB | Output is correct |
67 | Correct | 142 ms | 135180 KB | Output is correct |
68 | Correct | 134 ms | 135184 KB | Output is correct |
69 | Correct | 154 ms | 135240 KB | Output is correct |
70 | Correct | 164 ms | 135180 KB | Output is correct |
71 | Correct | 157 ms | 135108 KB | Output is correct |
72 | Correct | 159 ms | 135188 KB | Output is correct |
73 | Correct | 166 ms | 135080 KB | Output is correct |
74 | Correct | 138 ms | 135240 KB | Output is correct |
75 | Correct | 149 ms | 135184 KB | Output is correct |
76 | Correct | 172 ms | 135104 KB | Output is correct |
77 | Correct | 172 ms | 135184 KB | Output is correct |
78 | Correct | 143 ms | 135080 KB | Output is correct |
79 | Correct | 147 ms | 135180 KB | Output is correct |
80 | Correct | 175 ms | 135132 KB | Output is correct |
81 | Correct | 145 ms | 135120 KB | Output is correct |
82 | Correct | 157 ms | 135116 KB | Output is correct |
83 | Correct | 179 ms | 135184 KB | Output is correct |
84 | Correct | 156 ms | 135184 KB | Output is correct |
85 | Correct | 172 ms | 135116 KB | Output is correct |
86 | Correct | 163 ms | 135240 KB | Output is correct |
87 | Correct | 154 ms | 135180 KB | Output is correct |
88 | Correct | 161 ms | 135224 KB | Output is correct |
89 | Correct | 181 ms | 135116 KB | Output is correct |
90 | Correct | 152 ms | 135196 KB | Output is correct |
91 | Correct | 165 ms | 135184 KB | Output is correct |
92 | Correct | 196 ms | 135188 KB | Output is correct |
93 | Correct | 178 ms | 135180 KB | Output is correct |