Submission #569097

# Submission time Handle Problem Language Result Execution time Memory
569097 2022-05-26T16:24:32 Z MateGiorbelidze Collecting Stamps 3 (JOI20_ho_t3) C++14
25 / 100
169 ms 258132 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 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 0 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 1 ms 340 KB Output is correct
12 Correct 1 ms 884 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 852 KB Output is correct
17 Correct 1 ms 964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 0 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 1 ms 340 KB Output is correct
12 Correct 1 ms 884 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 852 KB Output is correct
17 Correct 1 ms 964 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 712 KB Output is correct
20 Correct 1 ms 980 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 580 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 964 KB Output is correct
33 Correct 1 ms 1236 KB Output is correct
34 Correct 1 ms 1220 KB Output is correct
35 Correct 1 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 0 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 1 ms 340 KB Output is correct
12 Correct 1 ms 884 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 852 KB Output is correct
17 Correct 1 ms 964 KB Output is correct
18 Correct 53 ms 103996 KB Output is correct
19 Correct 34 ms 63316 KB Output is correct
20 Correct 23 ms 33988 KB Output is correct
21 Correct 38 ms 59724 KB Output is correct
22 Correct 53 ms 77332 KB Output is correct
23 Correct 15 ms 28916 KB Output is correct
24 Correct 12 ms 22740 KB Output is correct
25 Correct 15 ms 28372 KB Output is correct
26 Correct 5 ms 10944 KB Output is correct
27 Correct 14 ms 29532 KB Output is correct
28 Correct 10 ms 21204 KB Output is correct
29 Correct 17 ms 30164 KB Output is correct
30 Correct 15 ms 23864 KB Output is correct
31 Correct 19 ms 28372 KB Output is correct
32 Correct 10 ms 15060 KB Output is correct
33 Correct 21 ms 28392 KB Output is correct
34 Correct 5 ms 10324 KB Output is correct
35 Correct 14 ms 27732 KB Output is correct
36 Correct 6 ms 13380 KB Output is correct
37 Correct 15 ms 29524 KB Output is correct
38 Correct 8 ms 16340 KB Output is correct
39 Correct 16 ms 30812 KB Output is correct
40 Correct 9 ms 18168 KB Output is correct
41 Correct 69 ms 127432 KB Output is correct
42 Correct 57 ms 86600 KB Output is correct
43 Correct 72 ms 127368 KB Output is correct
44 Correct 43 ms 85444 KB Output is correct
45 Correct 66 ms 127316 KB Output is correct
46 Correct 46 ms 86476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 0 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 1 ms 340 KB Output is correct
12 Correct 1 ms 884 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 852 KB Output is correct
17 Correct 1 ms 964 KB Output is correct
18 Correct 1 ms 1108 KB Output is correct
19 Correct 1 ms 712 KB Output is correct
20 Correct 1 ms 980 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 580 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 964 KB Output is correct
33 Correct 1 ms 1236 KB Output is correct
34 Correct 1 ms 1220 KB Output is correct
35 Correct 1 ms 1228 KB Output is correct
36 Correct 53 ms 103996 KB Output is correct
37 Correct 34 ms 63316 KB Output is correct
38 Correct 23 ms 33988 KB Output is correct
39 Correct 38 ms 59724 KB Output is correct
40 Correct 53 ms 77332 KB Output is correct
41 Correct 15 ms 28916 KB Output is correct
42 Correct 12 ms 22740 KB Output is correct
43 Correct 15 ms 28372 KB Output is correct
44 Correct 5 ms 10944 KB Output is correct
45 Correct 14 ms 29532 KB Output is correct
46 Correct 10 ms 21204 KB Output is correct
47 Correct 17 ms 30164 KB Output is correct
48 Correct 15 ms 23864 KB Output is correct
49 Correct 19 ms 28372 KB Output is correct
50 Correct 10 ms 15060 KB Output is correct
51 Correct 21 ms 28392 KB Output is correct
52 Correct 5 ms 10324 KB Output is correct
53 Correct 14 ms 27732 KB Output is correct
54 Correct 6 ms 13380 KB Output is correct
55 Correct 15 ms 29524 KB Output is correct
56 Correct 8 ms 16340 KB Output is correct
57 Correct 16 ms 30812 KB Output is correct
58 Correct 9 ms 18168 KB Output is correct
59 Correct 69 ms 127432 KB Output is correct
60 Correct 57 ms 86600 KB Output is correct
61 Correct 72 ms 127368 KB Output is correct
62 Correct 43 ms 85444 KB Output is correct
63 Correct 66 ms 127316 KB Output is correct
64 Correct 46 ms 86476 KB Output is correct
65 Correct 74 ms 115756 KB Output is correct
66 Correct 69 ms 106316 KB Output is correct
67 Correct 55 ms 101708 KB Output is correct
68 Correct 50 ms 94008 KB Output is correct
69 Correct 61 ms 114568 KB Output is correct
70 Correct 67 ms 109868 KB Output is correct
71 Correct 68 ms 111036 KB Output is correct
72 Correct 58 ms 112216 KB Output is correct
73 Correct 54 ms 104012 KB Output is correct
74 Correct 55 ms 97260 KB Output is correct
75 Correct 55 ms 107488 KB Output is correct
76 Correct 67 ms 123212 KB Output is correct
77 Correct 81 ms 123268 KB Output is correct
78 Correct 53 ms 95140 KB Output is correct
79 Correct 52 ms 98376 KB Output is correct
80 Correct 62 ms 120740 KB Output is correct
81 Correct 51 ms 99532 KB Output is correct
82 Correct 65 ms 105164 KB Output is correct
83 Correct 93 ms 127372 KB Output is correct
84 Correct 65 ms 109824 KB Output is correct
85 Correct 63 ms 119500 KB Output is correct
86 Correct 64 ms 117060 KB Output is correct
87 Correct 54 ms 107468 KB Output is correct
88 Runtime error 169 ms 258132 KB Execution killed with signal 11
89 Halted 0 ms 0 KB -