Submission #524599

# Submission time Handle Problem Language Result Execution time Memory
524599 2022-02-09T15:37:51 Z mosiashvililuka Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
90 ms 135940 KB
#include<bits/stdc++.h>
using namespace std;
const long long N=1000000009LL;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,L,dp[209][209][209][2],k,pas;
pair <long long, long long> p[209];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>L;
	for(i=1; i<=a; i++){
		cin>>p[i].first;
	}
	for(i=1; i<=a; i++){
		cin>>p[i].second;
	}
	for(i=0; i<=a+2; i++){
		for(j=0; j<=a+2; j++){
			for(ii=0; ii<=a+2; ii++){
				dp[i][j][ii][0]=dp[i][j][ii][1]=N;
			}
		}
	}
	dp[a+1][0][0][0]=dp[a+1][0][0][1]=0;
	p[a+1].first=L;
	for(ii=1; ii<=a; ii++){
		for(j=0; j<=ii; j++){
			i=ii-j;i=a+1-i;
			for(k=0; k<=ii; k++){
				if(j!=0){
					dp[i][j][k][1]=min(dp[i][j][k][1],dp[i][j-1][k][1]+p[j].first-p[j-1].first);
					if(k>0&&dp[i][j-1][k-1][1]+p[j].first-p[j-1].first<=p[j].second){
						dp[i][j][k][1]=min(dp[i][j][k][1],dp[i][j-1][k-1][1]+p[j].first-p[j-1].first);
					}
					zx=p[j].first+L-p[i].first;
					dp[i][j][k][1]=min(dp[i][j][k][1],dp[i][j-1][k][0]+zx);
					if(k>0&&dp[i][j-1][k-1][0]+zx<=p[j].second){
						dp[i][j][k][1]=min(dp[i][j][k][1],dp[i][j-1][k-1][0]+zx);
					}
				}
				if(i!=a+1){
					dp[i][j][k][0]=min(dp[i][j][k][0],dp[i+1][j][k][0]+p[i+1].first-p[i].first);
					if(k>0&&dp[i+1][j][k-1][0]+p[i+1].first-p[i].first<=p[i].second){
						dp[i][j][k][0]=min(dp[i][j][k][0],dp[i+1][j][k-1][0]+p[i+1].first-p[i].first);
					}
					zx=L-p[i].first+p[j].first;
					dp[i][j][k][0]=min(dp[i][j][k][0],dp[i+1][j][k][1]+zx);
					if(k>0&&dp[i+1][j][k-1][1]+zx<=p[i].second){
						dp[i][j][k][0]=min(dp[i][j][k][0],dp[i+1][j][k-1][1]+zx);
					}
				}
			}
		}
	}
	for(i=0; i<=a+1; i++){
		for(j=0; j<=a+1; j++){
			for(ii=0; ii<=a+1; ii++){
				if(dp[i][j][ii][0]!=N){
					pas=max(pas,ii);
				}
				if(dp[i][j][ii][1]!=N){
					pas=max(pas,ii);
				}
			}
		}
	}
	cout<<pas;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 440 KB Output is correct
2 Correct 1 ms 448 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 844 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 1088 KB Output is correct
13 Correct 1 ms 972 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 716 KB Output is correct
16 Correct 1 ms 972 KB Output is correct
17 Correct 1 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 440 KB Output is correct
2 Correct 1 ms 448 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 844 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 1088 KB Output is correct
13 Correct 1 ms 972 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 716 KB Output is correct
16 Correct 1 ms 972 KB Output is correct
17 Correct 1 ms 972 KB Output is correct
18 Correct 1 ms 1228 KB Output is correct
19 Correct 1 ms 832 KB Output is correct
20 Correct 1 ms 1092 KB Output is correct
21 Correct 1 ms 1228 KB Output is correct
22 Correct 1 ms 716 KB Output is correct
23 Correct 1 ms 1344 KB Output is correct
24 Correct 1 ms 1100 KB Output is correct
25 Correct 1 ms 1228 KB Output is correct
26 Correct 1 ms 1228 KB Output is correct
27 Correct 1 ms 716 KB Output is correct
28 Correct 1 ms 716 KB Output is correct
29 Correct 1 ms 1344 KB Output is correct
30 Correct 1 ms 1344 KB Output is correct
31 Correct 1 ms 1216 KB Output is correct
32 Correct 1 ms 1100 KB Output is correct
33 Correct 1 ms 1356 KB Output is correct
34 Correct 1 ms 1356 KB Output is correct
35 Correct 1 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 440 KB Output is correct
2 Correct 1 ms 448 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 844 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 1088 KB Output is correct
13 Correct 1 ms 972 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 716 KB Output is correct
16 Correct 1 ms 972 KB Output is correct
17 Correct 1 ms 972 KB Output is correct
18 Correct 72 ms 109296 KB Output is correct
19 Correct 44 ms 66756 KB Output is correct
20 Correct 24 ms 35972 KB Output is correct
21 Correct 42 ms 63084 KB Output is correct
22 Correct 53 ms 81472 KB Output is correct
23 Correct 20 ms 30668 KB Output is correct
24 Correct 15 ms 24168 KB Output is correct
25 Correct 18 ms 30116 KB Output is correct
26 Correct 7 ms 11852 KB Output is correct
27 Correct 22 ms 31308 KB Output is correct
28 Correct 13 ms 22476 KB Output is correct
29 Correct 20 ms 31948 KB Output is correct
30 Correct 19 ms 25212 KB Output is correct
31 Correct 18 ms 30028 KB Output is correct
32 Correct 9 ms 16076 KB Output is correct
33 Correct 17 ms 30032 KB Output is correct
34 Correct 6 ms 11084 KB Output is correct
35 Correct 18 ms 29512 KB Output is correct
36 Correct 8 ms 14276 KB Output is correct
37 Correct 20 ms 31392 KB Output is correct
38 Correct 11 ms 17484 KB Output is correct
39 Correct 20 ms 32588 KB Output is correct
40 Correct 11 ms 19404 KB Output is correct
41 Correct 85 ms 134604 KB Output is correct
42 Correct 55 ms 91072 KB Output is correct
43 Correct 87 ms 134604 KB Output is correct
44 Correct 54 ms 89920 KB Output is correct
45 Correct 84 ms 134580 KB Output is correct
46 Correct 58 ms 91064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 440 KB Output is correct
2 Correct 1 ms 448 KB Output is correct
3 Correct 1 ms 716 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 1 ms 588 KB Output is correct
6 Correct 1 ms 972 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 844 KB Output is correct
9 Correct 1 ms 972 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 1088 KB Output is correct
13 Correct 1 ms 972 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 716 KB Output is correct
16 Correct 1 ms 972 KB Output is correct
17 Correct 1 ms 972 KB Output is correct
18 Correct 1 ms 1228 KB Output is correct
19 Correct 1 ms 832 KB Output is correct
20 Correct 1 ms 1092 KB Output is correct
21 Correct 1 ms 1228 KB Output is correct
22 Correct 1 ms 716 KB Output is correct
23 Correct 1 ms 1344 KB Output is correct
24 Correct 1 ms 1100 KB Output is correct
25 Correct 1 ms 1228 KB Output is correct
26 Correct 1 ms 1228 KB Output is correct
27 Correct 1 ms 716 KB Output is correct
28 Correct 1 ms 716 KB Output is correct
29 Correct 1 ms 1344 KB Output is correct
30 Correct 1 ms 1344 KB Output is correct
31 Correct 1 ms 1216 KB Output is correct
32 Correct 1 ms 1100 KB Output is correct
33 Correct 1 ms 1356 KB Output is correct
34 Correct 1 ms 1356 KB Output is correct
35 Correct 1 ms 1356 KB Output is correct
36 Correct 72 ms 109296 KB Output is correct
37 Correct 44 ms 66756 KB Output is correct
38 Correct 24 ms 35972 KB Output is correct
39 Correct 42 ms 63084 KB Output is correct
40 Correct 53 ms 81472 KB Output is correct
41 Correct 20 ms 30668 KB Output is correct
42 Correct 15 ms 24168 KB Output is correct
43 Correct 18 ms 30116 KB Output is correct
44 Correct 7 ms 11852 KB Output is correct
45 Correct 22 ms 31308 KB Output is correct
46 Correct 13 ms 22476 KB Output is correct
47 Correct 20 ms 31948 KB Output is correct
48 Correct 19 ms 25212 KB Output is correct
49 Correct 18 ms 30028 KB Output is correct
50 Correct 9 ms 16076 KB Output is correct
51 Correct 17 ms 30032 KB Output is correct
52 Correct 6 ms 11084 KB Output is correct
53 Correct 18 ms 29512 KB Output is correct
54 Correct 8 ms 14276 KB Output is correct
55 Correct 20 ms 31392 KB Output is correct
56 Correct 11 ms 17484 KB Output is correct
57 Correct 20 ms 32588 KB Output is correct
58 Correct 11 ms 19404 KB Output is correct
59 Correct 85 ms 134604 KB Output is correct
60 Correct 55 ms 91072 KB Output is correct
61 Correct 87 ms 134604 KB Output is correct
62 Correct 54 ms 89920 KB Output is correct
63 Correct 84 ms 134580 KB Output is correct
64 Correct 58 ms 91064 KB Output is correct
65 Correct 78 ms 121652 KB Output is correct
66 Correct 71 ms 111772 KB Output is correct
67 Correct 71 ms 107076 KB Output is correct
68 Correct 60 ms 98816 KB Output is correct
69 Correct 74 ms 120404 KB Output is correct
70 Correct 72 ms 115396 KB Output is correct
71 Correct 72 ms 116676 KB Output is correct
72 Correct 73 ms 117828 KB Output is correct
73 Correct 68 ms 109364 KB Output is correct
74 Correct 70 ms 102304 KB Output is correct
75 Correct 75 ms 112940 KB Output is correct
76 Correct 81 ms 129332 KB Output is correct
77 Correct 82 ms 129256 KB Output is correct
78 Correct 64 ms 99952 KB Output is correct
79 Correct 69 ms 103348 KB Output is correct
80 Correct 81 ms 126812 KB Output is correct
81 Correct 64 ms 104584 KB Output is correct
82 Correct 68 ms 110500 KB Output is correct
83 Correct 83 ms 134592 KB Output is correct
84 Correct 71 ms 115392 KB Output is correct
85 Correct 79 ms 125356 KB Output is correct
86 Correct 77 ms 122924 KB Output is correct
87 Correct 70 ms 112976 KB Output is correct
88 Correct 85 ms 135892 KB Output is correct
89 Correct 85 ms 135940 KB Output is correct
90 Correct 80 ms 114276 KB Output is correct
91 Correct 90 ms 135896 KB Output is correct
92 Correct 88 ms 135936 KB Output is correct
93 Correct 82 ms 133188 KB Output is correct