Submission #532539

# Submission time Handle Problem Language Result Execution time Memory
532539 2022-03-03T06:26:42 Z amunduzbaev Collecting Stamps 3 (JOI20_ho_t3) C++17
15 / 100
98 ms 67748 KB
#include "bits/stdc++.h"
using namespace std;

#define ar array

const int N = 205;
int dp[2][N][N][N];
int x[N], t[N];

signed main(){
	ios::sync_with_stdio(0); cin.tie(0);
	
	int n, L; cin>>n>>L;
	for(int i=1;i<=n;i++) cin>>x[i];
	for(int i=1;i<=n;i++) cin>>t[i];
	x[n + 1] = L;
	
	memset(dp, 127, sizeof dp);
	int MX = dp[0][0][0][0];
	dp[0][0][n+1][0] = 
	dp[1][0][n+1][0] = 0;

	int res = 0;
	for(int c=0;c<=n;c++){
		for(int l=0;l<=n;l++){
			for(int r=n+1;r>l;r--){
				dp[0][l][r][c] = min(dp[0][l][r][c], dp[1][l][r][c] + L - x[r] + x[l]);
				dp[1][l][r][c] = min(dp[1][l][r][c], dp[0][l][r][c] + L - x[r] + x[l]);
				if(dp[0][l][r][c] < MX) res = max(res, c);
				if(dp[1][l][r][c] < MX) res = max(res, c);
				//~ if(l == 0 && r == 1){
					//~ cout<<l<<" "<<r<<" "<<c<<" "<<dp[0][l][r][c]<<" "<<dp[1][l][r][c]<<"\n";
				//~ }


				dp[0][l+1][r][c] = min(dp[0][l+1][r][c], dp[0][l][r][c] + x[l+1] - x[l]);
				if(dp[0][l][r][c] + x[l+1] - x[l] <= t[l+1]){
					dp[0][l+1][r][c+1] = min(dp[0][l+1][r][c+1], dp[0][l][r][c] + x[l+1] - x[l]);
				}
				dp[1][l][r-1][c] = min(dp[1][l][r-1][c], dp[1][l][r][c] + x[r] - x[r-1]);
				if(dp[1][l][r][c] + x[r] - x[r-1] <= t[r-1]){
					dp[1][l][r-1][c+1] = min(dp[1][l][r-1][c+1], dp[1][l][r][c] + x[r] - x[r-1]);
				}
			}
		}
	}
	
	cout<<res<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 26 ms 67660 KB Output is correct
2 Correct 26 ms 67692 KB Output is correct
3 Correct 26 ms 67652 KB Output is correct
4 Correct 27 ms 67652 KB Output is correct
5 Correct 27 ms 67708 KB Output is correct
6 Correct 27 ms 67660 KB Output is correct
7 Correct 28 ms 67660 KB Output is correct
8 Correct 29 ms 67672 KB Output is correct
9 Correct 35 ms 67708 KB Output is correct
10 Correct 30 ms 67640 KB Output is correct
11 Correct 26 ms 67660 KB Output is correct
12 Correct 26 ms 67660 KB Output is correct
13 Correct 27 ms 67640 KB Output is correct
14 Correct 26 ms 67652 KB Output is correct
15 Correct 26 ms 67660 KB Output is correct
16 Correct 26 ms 67744 KB Output is correct
17 Correct 26 ms 67628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 67660 KB Output is correct
2 Correct 26 ms 67692 KB Output is correct
3 Correct 26 ms 67652 KB Output is correct
4 Correct 27 ms 67652 KB Output is correct
5 Correct 27 ms 67708 KB Output is correct
6 Correct 27 ms 67660 KB Output is correct
7 Correct 28 ms 67660 KB Output is correct
8 Correct 29 ms 67672 KB Output is correct
9 Correct 35 ms 67708 KB Output is correct
10 Correct 30 ms 67640 KB Output is correct
11 Correct 26 ms 67660 KB Output is correct
12 Correct 26 ms 67660 KB Output is correct
13 Correct 27 ms 67640 KB Output is correct
14 Correct 26 ms 67652 KB Output is correct
15 Correct 26 ms 67660 KB Output is correct
16 Correct 26 ms 67744 KB Output is correct
17 Correct 26 ms 67628 KB Output is correct
18 Incorrect 27 ms 67660 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 67660 KB Output is correct
2 Correct 26 ms 67692 KB Output is correct
3 Correct 26 ms 67652 KB Output is correct
4 Correct 27 ms 67652 KB Output is correct
5 Correct 27 ms 67708 KB Output is correct
6 Correct 27 ms 67660 KB Output is correct
7 Correct 28 ms 67660 KB Output is correct
8 Correct 29 ms 67672 KB Output is correct
9 Correct 35 ms 67708 KB Output is correct
10 Correct 30 ms 67640 KB Output is correct
11 Correct 26 ms 67660 KB Output is correct
12 Correct 26 ms 67660 KB Output is correct
13 Correct 27 ms 67640 KB Output is correct
14 Correct 26 ms 67652 KB Output is correct
15 Correct 26 ms 67660 KB Output is correct
16 Correct 26 ms 67744 KB Output is correct
17 Correct 26 ms 67628 KB Output is correct
18 Correct 67 ms 67732 KB Output is correct
19 Correct 45 ms 67704 KB Output is correct
20 Correct 34 ms 67652 KB Output is correct
21 Correct 55 ms 67728 KB Output is correct
22 Correct 51 ms 67688 KB Output is correct
23 Correct 35 ms 67676 KB Output is correct
24 Correct 31 ms 67696 KB Output is correct
25 Correct 34 ms 67616 KB Output is correct
26 Correct 29 ms 67660 KB Output is correct
27 Correct 43 ms 67728 KB Output is correct
28 Correct 30 ms 67736 KB Output is correct
29 Correct 33 ms 67712 KB Output is correct
30 Correct 37 ms 67668 KB Output is correct
31 Correct 33 ms 67652 KB Output is correct
32 Correct 29 ms 67660 KB Output is correct
33 Correct 34 ms 67736 KB Output is correct
34 Correct 28 ms 67652 KB Output is correct
35 Correct 33 ms 67640 KB Output is correct
36 Correct 30 ms 67648 KB Output is correct
37 Correct 33 ms 67692 KB Output is correct
38 Correct 29 ms 67652 KB Output is correct
39 Correct 33 ms 67720 KB Output is correct
40 Correct 31 ms 67680 KB Output is correct
41 Correct 98 ms 67728 KB Output is correct
42 Correct 56 ms 67652 KB Output is correct
43 Correct 85 ms 67744 KB Output is correct
44 Correct 57 ms 67660 KB Output is correct
45 Correct 81 ms 67748 KB Output is correct
46 Correct 56 ms 67660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 67660 KB Output is correct
2 Correct 26 ms 67692 KB Output is correct
3 Correct 26 ms 67652 KB Output is correct
4 Correct 27 ms 67652 KB Output is correct
5 Correct 27 ms 67708 KB Output is correct
6 Correct 27 ms 67660 KB Output is correct
7 Correct 28 ms 67660 KB Output is correct
8 Correct 29 ms 67672 KB Output is correct
9 Correct 35 ms 67708 KB Output is correct
10 Correct 30 ms 67640 KB Output is correct
11 Correct 26 ms 67660 KB Output is correct
12 Correct 26 ms 67660 KB Output is correct
13 Correct 27 ms 67640 KB Output is correct
14 Correct 26 ms 67652 KB Output is correct
15 Correct 26 ms 67660 KB Output is correct
16 Correct 26 ms 67744 KB Output is correct
17 Correct 26 ms 67628 KB Output is correct
18 Incorrect 27 ms 67660 KB Output isn't correct
19 Halted 0 ms 0 KB -