Submission #647395

# Submission time Handle Problem Language Result Execution time Memory
647395 2022-10-02T11:25:29 Z beaconmc Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
138 ms 127440 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;


#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)

#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

ll n,l;
ll dp[201][201][201][2];

int main(){
	cin >> n >> l;
	vector<ll> dists(n+1);
	vector<ll> times(n+1);
	FOR(i,1,n+1) cin >> dists[i];
	FOR(i,1,n+1) cin >> times[i];
	FOR(i,0,201){
		FOR(j,0,201){
			FOR(k,0,201){
				dp[i][j][k][0] = 10000000000000;
				dp[i][j][k][1] = 10000000000000;
			}
		}
	}

	dp[n][0][0][1] = 0;
	dp[n][1][0][1] = dists[1];
	if (times[1] >= dists[1]) dp[n][1][1][1] = dists[1];



	// if (times[n] >= l-places[n]) dp[n][1][1][0] = l-places[n];
	// else dp[n][1][0][0] = l-places[n];

	// if (times[1] >= places[1]) dp[n][1][1][1] = places[1];
	// else dp[n][1][0][1] = places[1];

	FOR(k,0,n+1) FORNEG(i,n,-1) FOR(j,0,n+1){
		if (i<j) continue;


		if (i!=n){
			dp[i][j][k][0] = min(dp[i][j][k][0], dp[i+1][j][k][0] + dists[i+1] - dists[i]);

			if (k!=0){
				ll tm = dists[i+1] - dists[i] + dp[i+1][j][k-1][0];

				if (tm <= times[i]){
					dp[i][j][k][0] = min(dp[i][j][k][0], tm);
				}
			}

			dp[i][j][k][1] = min(dp[i][j][k][1], dp[i+1][j][k][0] + l + dists[j] - dists[i+1]);

			if (k!=0){
				ll tm = dp[i+1][j][k-1][0] + l + dists[j] - dists[i+1];

				if (tm <= times[j]){
					dp[i][j][k][1] = min(dp[i][j][k][1], tm);
				}
			}

		}

		if (j!=0){
			dp[i][j][k][1] = min(dp[i][j][k][1], dp[i][j-1][k][1] + dists[j] - dists[j-1]);

			if (k!=0){
				ll tm = dists[j] - dists[j-1] +  dp[i][j-1][k-1][1];

				if (tm <= times[j]){
					dp[i][j][k][1] = min(dp[i][j][k][1], tm);
				}
			}
			dp[i][j][k][0] = min(dp[i][j][k][0], dp[i][j-1][k][1] + l + dists[j-1] - dists[i]);

			if (k!=0){
				ll tm = dp[i][j-1][k-1][1] + l + dists[j-1] - dists[i];

				if (tm <= times[i]){
					dp[i][j][k][0] = min(dp[i][j][k][0], tm);
				}
			}

		}

	}


	ll ans = 0;

	FOR(i,0,201) FOR(j,0,201) FOR(k,0,201) FOR(m,0,2){

		if (dp[i][j][k][m] < 10000000000000) ans = max(ans, k);
	}

	// if (ans==7){

	// 	cout << n << " " << l << endl;
	// 	FOR(i,0,n+1) cout << dists[i] << " ";
	// 	cout << endl;
	// 	FOR(i,0,n+1) cout << times[i] << " ";
	// }
	// else cout << ans;
	cout << ans;


}
# Verdict Execution time Memory Grader output
1 Correct 62 ms 127304 KB Output is correct
2 Correct 73 ms 127288 KB Output is correct
3 Correct 66 ms 127336 KB Output is correct
4 Correct 64 ms 127408 KB Output is correct
5 Correct 64 ms 127308 KB Output is correct
6 Correct 67 ms 127364 KB Output is correct
7 Correct 69 ms 127368 KB Output is correct
8 Correct 77 ms 127308 KB Output is correct
9 Correct 67 ms 127408 KB Output is correct
10 Correct 64 ms 127324 KB Output is correct
11 Correct 77 ms 127412 KB Output is correct
12 Correct 65 ms 127324 KB Output is correct
13 Correct 66 ms 127316 KB Output is correct
14 Correct 66 ms 127408 KB Output is correct
15 Correct 61 ms 127316 KB Output is correct
16 Correct 67 ms 127408 KB Output is correct
17 Correct 68 ms 127408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 127304 KB Output is correct
2 Correct 73 ms 127288 KB Output is correct
3 Correct 66 ms 127336 KB Output is correct
4 Correct 64 ms 127408 KB Output is correct
5 Correct 64 ms 127308 KB Output is correct
6 Correct 67 ms 127364 KB Output is correct
7 Correct 69 ms 127368 KB Output is correct
8 Correct 77 ms 127308 KB Output is correct
9 Correct 67 ms 127408 KB Output is correct
10 Correct 64 ms 127324 KB Output is correct
11 Correct 77 ms 127412 KB Output is correct
12 Correct 65 ms 127324 KB Output is correct
13 Correct 66 ms 127316 KB Output is correct
14 Correct 66 ms 127408 KB Output is correct
15 Correct 61 ms 127316 KB Output is correct
16 Correct 67 ms 127408 KB Output is correct
17 Correct 68 ms 127408 KB Output is correct
18 Correct 80 ms 127388 KB Output is correct
19 Correct 61 ms 127404 KB Output is correct
20 Correct 67 ms 127408 KB Output is correct
21 Correct 73 ms 127404 KB Output is correct
22 Correct 81 ms 127364 KB Output is correct
23 Correct 80 ms 127404 KB Output is correct
24 Correct 60 ms 127308 KB Output is correct
25 Correct 70 ms 127408 KB Output is correct
26 Correct 62 ms 127348 KB Output is correct
27 Correct 82 ms 127408 KB Output is correct
28 Correct 72 ms 127308 KB Output is correct
29 Correct 65 ms 127304 KB Output is correct
30 Correct 74 ms 127340 KB Output is correct
31 Correct 68 ms 127348 KB Output is correct
32 Correct 64 ms 127340 KB Output is correct
33 Correct 72 ms 127412 KB Output is correct
34 Correct 67 ms 127392 KB Output is correct
35 Correct 64 ms 127308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 127304 KB Output is correct
2 Correct 73 ms 127288 KB Output is correct
3 Correct 66 ms 127336 KB Output is correct
4 Correct 64 ms 127408 KB Output is correct
5 Correct 64 ms 127308 KB Output is correct
6 Correct 67 ms 127364 KB Output is correct
7 Correct 69 ms 127368 KB Output is correct
8 Correct 77 ms 127308 KB Output is correct
9 Correct 67 ms 127408 KB Output is correct
10 Correct 64 ms 127324 KB Output is correct
11 Correct 77 ms 127412 KB Output is correct
12 Correct 65 ms 127324 KB Output is correct
13 Correct 66 ms 127316 KB Output is correct
14 Correct 66 ms 127408 KB Output is correct
15 Correct 61 ms 127316 KB Output is correct
16 Correct 67 ms 127408 KB Output is correct
17 Correct 68 ms 127408 KB Output is correct
18 Correct 108 ms 127416 KB Output is correct
19 Correct 81 ms 127408 KB Output is correct
20 Correct 72 ms 127340 KB Output is correct
21 Correct 86 ms 127388 KB Output is correct
22 Correct 96 ms 127336 KB Output is correct
23 Correct 76 ms 127376 KB Output is correct
24 Correct 67 ms 127360 KB Output is correct
25 Correct 74 ms 127404 KB Output is correct
26 Correct 66 ms 127436 KB Output is correct
27 Correct 78 ms 127340 KB Output is correct
28 Correct 67 ms 127412 KB Output is correct
29 Correct 69 ms 127404 KB Output is correct
30 Correct 67 ms 127408 KB Output is correct
31 Correct 95 ms 127324 KB Output is correct
32 Correct 79 ms 127404 KB Output is correct
33 Correct 83 ms 127368 KB Output is correct
34 Correct 73 ms 127340 KB Output is correct
35 Correct 82 ms 127372 KB Output is correct
36 Correct 79 ms 127328 KB Output is correct
37 Correct 82 ms 127308 KB Output is correct
38 Correct 68 ms 127392 KB Output is correct
39 Correct 70 ms 127308 KB Output is correct
40 Correct 71 ms 127296 KB Output is correct
41 Correct 133 ms 127412 KB Output is correct
42 Correct 93 ms 127364 KB Output is correct
43 Correct 118 ms 127372 KB Output is correct
44 Correct 100 ms 127380 KB Output is correct
45 Correct 129 ms 127412 KB Output is correct
46 Correct 96 ms 127408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 127304 KB Output is correct
2 Correct 73 ms 127288 KB Output is correct
3 Correct 66 ms 127336 KB Output is correct
4 Correct 64 ms 127408 KB Output is correct
5 Correct 64 ms 127308 KB Output is correct
6 Correct 67 ms 127364 KB Output is correct
7 Correct 69 ms 127368 KB Output is correct
8 Correct 77 ms 127308 KB Output is correct
9 Correct 67 ms 127408 KB Output is correct
10 Correct 64 ms 127324 KB Output is correct
11 Correct 77 ms 127412 KB Output is correct
12 Correct 65 ms 127324 KB Output is correct
13 Correct 66 ms 127316 KB Output is correct
14 Correct 66 ms 127408 KB Output is correct
15 Correct 61 ms 127316 KB Output is correct
16 Correct 67 ms 127408 KB Output is correct
17 Correct 68 ms 127408 KB Output is correct
18 Correct 80 ms 127388 KB Output is correct
19 Correct 61 ms 127404 KB Output is correct
20 Correct 67 ms 127408 KB Output is correct
21 Correct 73 ms 127404 KB Output is correct
22 Correct 81 ms 127364 KB Output is correct
23 Correct 80 ms 127404 KB Output is correct
24 Correct 60 ms 127308 KB Output is correct
25 Correct 70 ms 127408 KB Output is correct
26 Correct 62 ms 127348 KB Output is correct
27 Correct 82 ms 127408 KB Output is correct
28 Correct 72 ms 127308 KB Output is correct
29 Correct 65 ms 127304 KB Output is correct
30 Correct 74 ms 127340 KB Output is correct
31 Correct 68 ms 127348 KB Output is correct
32 Correct 64 ms 127340 KB Output is correct
33 Correct 72 ms 127412 KB Output is correct
34 Correct 67 ms 127392 KB Output is correct
35 Correct 64 ms 127308 KB Output is correct
36 Correct 108 ms 127416 KB Output is correct
37 Correct 81 ms 127408 KB Output is correct
38 Correct 72 ms 127340 KB Output is correct
39 Correct 86 ms 127388 KB Output is correct
40 Correct 96 ms 127336 KB Output is correct
41 Correct 76 ms 127376 KB Output is correct
42 Correct 67 ms 127360 KB Output is correct
43 Correct 74 ms 127404 KB Output is correct
44 Correct 66 ms 127436 KB Output is correct
45 Correct 78 ms 127340 KB Output is correct
46 Correct 67 ms 127412 KB Output is correct
47 Correct 69 ms 127404 KB Output is correct
48 Correct 67 ms 127408 KB Output is correct
49 Correct 95 ms 127324 KB Output is correct
50 Correct 79 ms 127404 KB Output is correct
51 Correct 83 ms 127368 KB Output is correct
52 Correct 73 ms 127340 KB Output is correct
53 Correct 82 ms 127372 KB Output is correct
54 Correct 79 ms 127328 KB Output is correct
55 Correct 82 ms 127308 KB Output is correct
56 Correct 68 ms 127392 KB Output is correct
57 Correct 70 ms 127308 KB Output is correct
58 Correct 71 ms 127296 KB Output is correct
59 Correct 133 ms 127412 KB Output is correct
60 Correct 93 ms 127364 KB Output is correct
61 Correct 118 ms 127372 KB Output is correct
62 Correct 100 ms 127380 KB Output is correct
63 Correct 129 ms 127412 KB Output is correct
64 Correct 96 ms 127408 KB Output is correct
65 Correct 118 ms 127308 KB Output is correct
66 Correct 126 ms 127412 KB Output is correct
67 Correct 117 ms 127360 KB Output is correct
68 Correct 107 ms 127416 KB Output is correct
69 Correct 114 ms 127404 KB Output is correct
70 Correct 113 ms 127404 KB Output is correct
71 Correct 121 ms 127368 KB Output is correct
72 Correct 111 ms 127364 KB Output is correct
73 Correct 116 ms 127412 KB Output is correct
74 Correct 114 ms 127412 KB Output is correct
75 Correct 118 ms 127408 KB Output is correct
76 Correct 125 ms 127392 KB Output is correct
77 Correct 138 ms 127416 KB Output is correct
78 Correct 102 ms 127300 KB Output is correct
79 Correct 108 ms 127404 KB Output is correct
80 Correct 117 ms 127436 KB Output is correct
81 Correct 97 ms 127380 KB Output is correct
82 Correct 102 ms 127308 KB Output is correct
83 Correct 111 ms 127336 KB Output is correct
84 Correct 108 ms 127412 KB Output is correct
85 Correct 132 ms 127432 KB Output is correct
86 Correct 109 ms 127348 KB Output is correct
87 Correct 99 ms 127300 KB Output is correct
88 Correct 119 ms 127408 KB Output is correct
89 Correct 128 ms 127440 KB Output is correct
90 Correct 107 ms 127352 KB Output is correct
91 Correct 113 ms 127332 KB Output is correct
92 Correct 120 ms 127408 KB Output is correct
93 Correct 126 ms 127408 KB Output is correct