Submission #569098

# Submission time Handle Problem Language Result Execution time Memory
569098 2022-05-26T16:25:21 Z MateGiorbelidze Collecting Stamps 3 (JOI20_ho_t3) C++14
25 / 100
201 ms 258160 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ff first
#define sc second
#define pb push_back
#define in insert
 
 
const ll MXT = 2000000000000;
 
ll dp[201][201][201][2];
int32_t main () {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n , l; cin>>n>>l;
    
    ll a[n + 2],t[n + 2];
    
    for (int i = 1; i <= n; i++)
    	cin>>a[i];
    	
    for (int i = 1; i <= n; i++)	
    	cin>>t[i];
    	
    for(int i = 0; i <= n + 1; i++)
		for(int j = 0; j <= n + 1; j++)
			for(int k = 0; k <= n + 1; k++)
				dp[i][j][k][0] = dp[i][j][k][1] = MXT;
				
	dp[n + 1][0][0][0] = dp[n + 1][0][0][1] = 0;
	
	a[0] = 0 ;
	a[n + 1] = l;
	for(int i = n + 1; i > 1; i--){
		for (int j = 0; j <= i; j++) {
			for(int k = 0; k <= n; k++) {
				
				ll mn = dp[i][j][k][0] + a[j + 1] - a[j];
				mn = min(mn , dp[i][j][k][1] + l - a[i] + a[j + 1]);
				
				if (mn <= t[j + 1]) dp[i][j + 1][k + 1][0] = min(mn , dp[i][j + 1][k + 1][0]);
				else dp[i][j + 1][k][0] = min(mn , dp[i][j + 1][k][0]);
				
				mn = dp[i][j][k][0] + a[j] + l - a[i - 1];
				mn = min(mn , dp[i][j][k][1] - a[i - 1] + a[i]);
				
				if (mn <= t[i - 1]) dp[i - 1][j][k + 1][1] = min(mn , dp[i - 1][j][k + 1][1]);
				else dp[i - 1][j][k][1] = min(mn , dp[i - 1][j][k][1]);
			}
			
		}
	}
	ll ans = 0;
	
	for (int j = 0; j <= n; j++) {
		for (ll k = 1; k <= n; k++) {
			if(dp[j + 1][j][k][0] != MXT) ans = max(k, ans);
        	if(dp[j + 1][j][k][1] != MXT) ans = max(k, ans);
		}
	}	
	cout<<ans;			
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 724 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 1236 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 1 ms 724 KB Output is correct
29 Correct 1 ms 1236 KB Output is correct
30 Correct 1 ms 1236 KB Output is correct
31 Correct 1 ms 1108 KB Output is correct
32 Correct 1 ms 980 KB Output is correct
33 Correct 1 ms 1236 KB Output is correct
34 Correct 1 ms 1236 KB Output is correct
35 Correct 1 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 57 ms 104028 KB Output is correct
19 Correct 41 ms 63268 KB Output is correct
20 Correct 19 ms 34024 KB Output is correct
21 Correct 39 ms 59800 KB Output is correct
22 Correct 41 ms 77424 KB Output is correct
23 Correct 15 ms 29012 KB Output is correct
24 Correct 12 ms 22740 KB Output is correct
25 Correct 15 ms 28372 KB Output is correct
26 Correct 6 ms 10964 KB Output is correct
27 Correct 16 ms 29524 KB Output is correct
28 Correct 13 ms 21204 KB Output is correct
29 Correct 18 ms 30252 KB Output is correct
30 Correct 13 ms 23776 KB Output is correct
31 Correct 15 ms 28372 KB Output is correct
32 Correct 8 ms 15060 KB Output is correct
33 Correct 15 ms 28372 KB Output is correct
34 Correct 7 ms 10352 KB Output is correct
35 Correct 14 ms 27732 KB Output is correct
36 Correct 7 ms 13268 KB Output is correct
37 Correct 15 ms 29616 KB Output is correct
38 Correct 8 ms 16312 KB Output is correct
39 Correct 16 ms 30804 KB Output is correct
40 Correct 10 ms 18132 KB Output is correct
41 Correct 87 ms 127416 KB Output is correct
42 Correct 52 ms 86580 KB Output is correct
43 Correct 69 ms 127432 KB Output is correct
44 Correct 48 ms 85532 KB Output is correct
45 Correct 74 ms 127344 KB Output is correct
46 Correct 54 ms 86580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 852 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 724 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 724 KB Output is correct
20 Correct 1 ms 852 KB Output is correct
21 Correct 1 ms 1108 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 1236 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 1108 KB Output is correct
26 Correct 1 ms 1108 KB Output is correct
27 Correct 1 ms 596 KB Output is correct
28 Correct 1 ms 724 KB Output is correct
29 Correct 1 ms 1236 KB Output is correct
30 Correct 1 ms 1236 KB Output is correct
31 Correct 1 ms 1108 KB Output is correct
32 Correct 1 ms 980 KB Output is correct
33 Correct 1 ms 1236 KB Output is correct
34 Correct 1 ms 1236 KB Output is correct
35 Correct 1 ms 1236 KB Output is correct
36 Correct 57 ms 104028 KB Output is correct
37 Correct 41 ms 63268 KB Output is correct
38 Correct 19 ms 34024 KB Output is correct
39 Correct 39 ms 59800 KB Output is correct
40 Correct 41 ms 77424 KB Output is correct
41 Correct 15 ms 29012 KB Output is correct
42 Correct 12 ms 22740 KB Output is correct
43 Correct 15 ms 28372 KB Output is correct
44 Correct 6 ms 10964 KB Output is correct
45 Correct 16 ms 29524 KB Output is correct
46 Correct 13 ms 21204 KB Output is correct
47 Correct 18 ms 30252 KB Output is correct
48 Correct 13 ms 23776 KB Output is correct
49 Correct 15 ms 28372 KB Output is correct
50 Correct 8 ms 15060 KB Output is correct
51 Correct 15 ms 28372 KB Output is correct
52 Correct 7 ms 10352 KB Output is correct
53 Correct 14 ms 27732 KB Output is correct
54 Correct 7 ms 13268 KB Output is correct
55 Correct 15 ms 29616 KB Output is correct
56 Correct 8 ms 16312 KB Output is correct
57 Correct 16 ms 30804 KB Output is correct
58 Correct 10 ms 18132 KB Output is correct
59 Correct 87 ms 127416 KB Output is correct
60 Correct 52 ms 86580 KB Output is correct
61 Correct 69 ms 127432 KB Output is correct
62 Correct 48 ms 85532 KB Output is correct
63 Correct 74 ms 127344 KB Output is correct
64 Correct 54 ms 86580 KB Output is correct
65 Correct 64 ms 115844 KB Output is correct
66 Correct 56 ms 106336 KB Output is correct
67 Correct 51 ms 101696 KB Output is correct
68 Correct 49 ms 93964 KB Output is correct
69 Correct 63 ms 114764 KB Output is correct
70 Correct 56 ms 109892 KB Output is correct
71 Correct 59 ms 111000 KB Output is correct
72 Correct 59 ms 112176 KB Output is correct
73 Correct 75 ms 104024 KB Output is correct
74 Correct 67 ms 97220 KB Output is correct
75 Correct 61 ms 107496 KB Output is correct
76 Correct 66 ms 123112 KB Output is correct
77 Correct 67 ms 123112 KB Output is correct
78 Correct 53 ms 95100 KB Output is correct
79 Correct 51 ms 98444 KB Output is correct
80 Correct 67 ms 120672 KB Output is correct
81 Correct 56 ms 99564 KB Output is correct
82 Correct 73 ms 105232 KB Output is correct
83 Correct 98 ms 127320 KB Output is correct
84 Correct 61 ms 109772 KB Output is correct
85 Correct 69 ms 119496 KB Output is correct
86 Correct 73 ms 117036 KB Output is correct
87 Correct 60 ms 107500 KB Output is correct
88 Runtime error 201 ms 258160 KB Execution killed with signal 11
89 Halted 0 ms 0 KB -