Submission #534566

# Submission time Handle Problem Language Result Execution time Memory
534566 2022-03-08T10:08:10 Z alvingogo Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
82 ms 135308 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
//#define int long long
using namespace std;

typedef long long ll;
const ll inf=2e16;
ll dp[205][205][205][2];
int main(){
	AquA;
	int n;
	ll l;
	cin >> n >> l;
	vector<ll> v(n+3),rv(n+3),t(n+3),rt(n+3);
	t[0]=rt[0]=4e9;
	rv[0]=l;
	v[0]=0;
	for(int i=1;i<=n;i++){
		cin >> v[i];
		rv[n-i+1]=v[i];
	}
	for(int i=1;i<=n;i++){
		cin >> t[i];
		rt[n-i+1]=t[i];
	}
	for(int i=0;i<205;i++){
		for(int j=0;j<205;j++){
			for(int k=0;k<205;k++){
				dp[i][j][k][0]=dp[i][j][k][1]=inf;
			}
		}
	}
	dp[0][0][0][0]=dp[0][0][0][1]=0;
	int maxx=0;
	for(int len=0;len<=n;len++){
		for(int i=0;i<=len;i++){
			int j=len-i;
			for(int k=0;k<=len;k++){
				ll z=dp[i][j][k][0];
				if(z!=inf){
					maxx=max(maxx,k);
				}
				if(z+v[i+1]-v[i]<=t[i+1]){
					dp[i+1][j][k+1][0]=min(dp[i+1][j][k+1][0],z+v[i+1]-v[i]);
				}
				else{
					dp[i+1][j][k][0]=min(dp[i+1][j][k][0],z+v[i+1]-v[i]);
				}
				if(z+v[i]-v[0]+rv[0]-rv[j+1]<=rt[j+1]){
					dp[i][j+1][k+1][1]=min(dp[i][j+1][k+1][1],z+v[i]-v[0]+rv[0]-rv[j+1]);
				}
				else{
					dp[i][j+1][k][1]=min(dp[i][j+1][k][1],z+v[i]-v[0]+rv[0]-rv[j+1]);
				}
				z=dp[i][j][k][1];
				if(z!=inf){
					maxx=max(maxx,k);
				}
				if(z+rv[j]-rv[j+1]<=rt[j+1]){
					dp[i][j+1][k+1][1]=min(dp[i][j+1][k+1][1],z+rv[j]-rv[j+1]);
				}
				else{
					dp[i][j+1][k][1]=min(dp[i][j+1][k][1],z+rv[j]-rv[j+1]);
				}
				if(z+rv[0]-rv[j]+v[i+1]-v[0]<=t[i+1]){
					dp[i+1][j][k+1][0]=min(dp[i+1][j][k+1][0],z+rv[0]-rv[j]+v[i+1]-v[0]);
				}
				else{
					dp[i+1][j][k][0]=min(dp[i+1][j][k][0],z+rv[0]-rv[j]+v[i+1]-v[0]);
				}
			}
		}
	}
	cout << maxx << "\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 50 ms 135064 KB Output is correct
2 Correct 53 ms 135136 KB Output is correct
3 Correct 56 ms 135172 KB Output is correct
4 Correct 60 ms 135164 KB Output is correct
5 Correct 56 ms 135108 KB Output is correct
6 Correct 59 ms 135112 KB Output is correct
7 Correct 61 ms 135060 KB Output is correct
8 Correct 63 ms 135064 KB Output is correct
9 Correct 52 ms 135136 KB Output is correct
10 Correct 55 ms 135136 KB Output is correct
11 Correct 61 ms 135128 KB Output is correct
12 Correct 50 ms 135140 KB Output is correct
13 Correct 54 ms 135108 KB Output is correct
14 Correct 51 ms 135060 KB Output is correct
15 Correct 49 ms 135108 KB Output is correct
16 Correct 58 ms 135128 KB Output is correct
17 Correct 62 ms 135108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 135064 KB Output is correct
2 Correct 53 ms 135136 KB Output is correct
3 Correct 56 ms 135172 KB Output is correct
4 Correct 60 ms 135164 KB Output is correct
5 Correct 56 ms 135108 KB Output is correct
6 Correct 59 ms 135112 KB Output is correct
7 Correct 61 ms 135060 KB Output is correct
8 Correct 63 ms 135064 KB Output is correct
9 Correct 52 ms 135136 KB Output is correct
10 Correct 55 ms 135136 KB Output is correct
11 Correct 61 ms 135128 KB Output is correct
12 Correct 50 ms 135140 KB Output is correct
13 Correct 54 ms 135108 KB Output is correct
14 Correct 51 ms 135060 KB Output is correct
15 Correct 49 ms 135108 KB Output is correct
16 Correct 58 ms 135128 KB Output is correct
17 Correct 62 ms 135108 KB Output is correct
18 Correct 53 ms 135104 KB Output is correct
19 Correct 52 ms 135124 KB Output is correct
20 Correct 53 ms 135308 KB Output is correct
21 Correct 50 ms 135052 KB Output is correct
22 Correct 48 ms 135148 KB Output is correct
23 Correct 54 ms 135088 KB Output is correct
24 Correct 52 ms 135100 KB Output is correct
25 Correct 49 ms 135088 KB Output is correct
26 Correct 49 ms 135104 KB Output is correct
27 Correct 52 ms 135100 KB Output is correct
28 Correct 54 ms 135124 KB Output is correct
29 Correct 54 ms 135084 KB Output is correct
30 Correct 52 ms 135108 KB Output is correct
31 Correct 49 ms 135052 KB Output is correct
32 Correct 48 ms 135048 KB Output is correct
33 Correct 48 ms 135160 KB Output is correct
34 Correct 53 ms 135132 KB Output is correct
35 Correct 53 ms 135120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 135064 KB Output is correct
2 Correct 53 ms 135136 KB Output is correct
3 Correct 56 ms 135172 KB Output is correct
4 Correct 60 ms 135164 KB Output is correct
5 Correct 56 ms 135108 KB Output is correct
6 Correct 59 ms 135112 KB Output is correct
7 Correct 61 ms 135060 KB Output is correct
8 Correct 63 ms 135064 KB Output is correct
9 Correct 52 ms 135136 KB Output is correct
10 Correct 55 ms 135136 KB Output is correct
11 Correct 61 ms 135128 KB Output is correct
12 Correct 50 ms 135140 KB Output is correct
13 Correct 54 ms 135108 KB Output is correct
14 Correct 51 ms 135060 KB Output is correct
15 Correct 49 ms 135108 KB Output is correct
16 Correct 58 ms 135128 KB Output is correct
17 Correct 62 ms 135108 KB Output is correct
18 Correct 70 ms 135168 KB Output is correct
19 Correct 55 ms 135168 KB Output is correct
20 Correct 52 ms 135104 KB Output is correct
21 Correct 54 ms 135096 KB Output is correct
22 Correct 60 ms 135168 KB Output is correct
23 Correct 51 ms 135108 KB Output is correct
24 Correct 50 ms 135112 KB Output is correct
25 Correct 53 ms 135080 KB Output is correct
26 Correct 62 ms 135140 KB Output is correct
27 Correct 53 ms 135240 KB Output is correct
28 Correct 51 ms 135092 KB Output is correct
29 Correct 54 ms 135056 KB Output is correct
30 Correct 55 ms 135224 KB Output is correct
31 Correct 55 ms 135048 KB Output is correct
32 Correct 56 ms 135076 KB Output is correct
33 Correct 55 ms 135112 KB Output is correct
34 Correct 50 ms 135128 KB Output is correct
35 Correct 50 ms 135160 KB Output is correct
36 Correct 48 ms 135140 KB Output is correct
37 Correct 55 ms 135208 KB Output is correct
38 Correct 51 ms 135116 KB Output is correct
39 Correct 67 ms 135064 KB Output is correct
40 Correct 59 ms 135076 KB Output is correct
41 Correct 67 ms 135108 KB Output is correct
42 Correct 59 ms 135168 KB Output is correct
43 Correct 72 ms 135068 KB Output is correct
44 Correct 66 ms 135252 KB Output is correct
45 Correct 82 ms 135176 KB Output is correct
46 Correct 60 ms 135160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 135064 KB Output is correct
2 Correct 53 ms 135136 KB Output is correct
3 Correct 56 ms 135172 KB Output is correct
4 Correct 60 ms 135164 KB Output is correct
5 Correct 56 ms 135108 KB Output is correct
6 Correct 59 ms 135112 KB Output is correct
7 Correct 61 ms 135060 KB Output is correct
8 Correct 63 ms 135064 KB Output is correct
9 Correct 52 ms 135136 KB Output is correct
10 Correct 55 ms 135136 KB Output is correct
11 Correct 61 ms 135128 KB Output is correct
12 Correct 50 ms 135140 KB Output is correct
13 Correct 54 ms 135108 KB Output is correct
14 Correct 51 ms 135060 KB Output is correct
15 Correct 49 ms 135108 KB Output is correct
16 Correct 58 ms 135128 KB Output is correct
17 Correct 62 ms 135108 KB Output is correct
18 Correct 53 ms 135104 KB Output is correct
19 Correct 52 ms 135124 KB Output is correct
20 Correct 53 ms 135308 KB Output is correct
21 Correct 50 ms 135052 KB Output is correct
22 Correct 48 ms 135148 KB Output is correct
23 Correct 54 ms 135088 KB Output is correct
24 Correct 52 ms 135100 KB Output is correct
25 Correct 49 ms 135088 KB Output is correct
26 Correct 49 ms 135104 KB Output is correct
27 Correct 52 ms 135100 KB Output is correct
28 Correct 54 ms 135124 KB Output is correct
29 Correct 54 ms 135084 KB Output is correct
30 Correct 52 ms 135108 KB Output is correct
31 Correct 49 ms 135052 KB Output is correct
32 Correct 48 ms 135048 KB Output is correct
33 Correct 48 ms 135160 KB Output is correct
34 Correct 53 ms 135132 KB Output is correct
35 Correct 53 ms 135120 KB Output is correct
36 Correct 70 ms 135168 KB Output is correct
37 Correct 55 ms 135168 KB Output is correct
38 Correct 52 ms 135104 KB Output is correct
39 Correct 54 ms 135096 KB Output is correct
40 Correct 60 ms 135168 KB Output is correct
41 Correct 51 ms 135108 KB Output is correct
42 Correct 50 ms 135112 KB Output is correct
43 Correct 53 ms 135080 KB Output is correct
44 Correct 62 ms 135140 KB Output is correct
45 Correct 53 ms 135240 KB Output is correct
46 Correct 51 ms 135092 KB Output is correct
47 Correct 54 ms 135056 KB Output is correct
48 Correct 55 ms 135224 KB Output is correct
49 Correct 55 ms 135048 KB Output is correct
50 Correct 56 ms 135076 KB Output is correct
51 Correct 55 ms 135112 KB Output is correct
52 Correct 50 ms 135128 KB Output is correct
53 Correct 50 ms 135160 KB Output is correct
54 Correct 48 ms 135140 KB Output is correct
55 Correct 55 ms 135208 KB Output is correct
56 Correct 51 ms 135116 KB Output is correct
57 Correct 67 ms 135064 KB Output is correct
58 Correct 59 ms 135076 KB Output is correct
59 Correct 67 ms 135108 KB Output is correct
60 Correct 59 ms 135168 KB Output is correct
61 Correct 72 ms 135068 KB Output is correct
62 Correct 66 ms 135252 KB Output is correct
63 Correct 82 ms 135176 KB Output is correct
64 Correct 60 ms 135160 KB Output is correct
65 Correct 71 ms 135140 KB Output is correct
66 Correct 65 ms 135072 KB Output is correct
67 Correct 65 ms 135112 KB Output is correct
68 Correct 74 ms 135108 KB Output is correct
69 Correct 68 ms 135120 KB Output is correct
70 Correct 63 ms 135080 KB Output is correct
71 Correct 63 ms 135108 KB Output is correct
72 Correct 70 ms 135108 KB Output is correct
73 Correct 75 ms 135108 KB Output is correct
74 Correct 70 ms 135176 KB Output is correct
75 Correct 65 ms 135068 KB Output is correct
76 Correct 70 ms 135108 KB Output is correct
77 Correct 68 ms 135080 KB Output is correct
78 Correct 75 ms 135084 KB Output is correct
79 Correct 67 ms 135172 KB Output is correct
80 Correct 71 ms 135108 KB Output is correct
81 Correct 63 ms 135108 KB Output is correct
82 Correct 63 ms 135096 KB Output is correct
83 Correct 67 ms 135124 KB Output is correct
84 Correct 64 ms 135176 KB Output is correct
85 Correct 73 ms 135144 KB Output is correct
86 Correct 70 ms 135104 KB Output is correct
87 Correct 64 ms 135168 KB Output is correct
88 Correct 68 ms 135108 KB Output is correct
89 Correct 74 ms 135188 KB Output is correct
90 Correct 66 ms 135180 KB Output is correct
91 Correct 76 ms 135108 KB Output is correct
92 Correct 80 ms 135096 KB Output is correct
93 Correct 66 ms 135072 KB Output is correct