Submission #568160

# Submission time Handle Problem Language Result Execution time Memory
568160 2022-05-24T18:03:00 Z Ronin13 Collecting Stamps 3 (JOI20_ho_t3) C++14
15 / 100
65 ms 127564 KB
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;

const int inf = 1e9 + 1;
const ll linf = 1e18 + 1;

ll dp[201][201][201][2];

int main(){
    ll n, l;
    cin >> n >> l;
    ll a[n + 2];
    ll t[n + 1];
    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 <= 200; i++){
        for(int j = 0; j <= 200; j++){
            for(int k = 0; k <= 200; k++) dp[i][j][k][0] = dp[i][j][k][1] = linf;
        }
    }
    dp[0][0][0][0] = 0;
    a[0] = 0;
    a[n + 1] = l;
    // 0 marcxniv 1 marjvniv
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(i + j > n) continue;
            for(int x = 0; x < n; x++){
                ll nt = dp[i][j][x][0] + l - a[n - i + 1] + a[j + 1];
                nt = min(nt, dp[i][j][x][1] + a[j + 1] - a[j]);
                if(nt <= t[j + 1]) dp[i][j + 1][x + 1][1] = min(dp[i][j + 1][x + 1][1], nt);
                else dp[i][j + 1][x][1] = min(dp[i][j + 1][x][1], nt);
                nt = dp[i][j][x][0] + a[n - i + 1] - a[n - i];
                nt = min(nt, dp[i][j][x][1] + l - a[n - i] + a[j]);
                if(nt <= t[n - i]) dp[i + 1][j][x + 1][0] = min(dp[i + 1][j][x + 1][0], nt);
                else dp[i + 1][j][x][0] = min(dp[i + 1][j][x][0], nt);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int x = 1; x <= n; x++) {
            if(dp[i][n - i][x][0] != linf) ans = max(x, ans);
            if(dp[i][n - i][x][1] != linf) ans = max(x, ans);
        }
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 51 ms 127308 KB Output is correct
2 Correct 50 ms 127364 KB Output is correct
3 Correct 52 ms 127328 KB Output is correct
4 Correct 53 ms 127364 KB Output is correct
5 Correct 50 ms 127344 KB Output is correct
6 Correct 50 ms 127316 KB Output is correct
7 Correct 53 ms 127336 KB Output is correct
8 Correct 51 ms 127376 KB Output is correct
9 Correct 50 ms 127344 KB Output is correct
10 Correct 51 ms 127408 KB Output is correct
11 Correct 50 ms 127344 KB Output is correct
12 Correct 52 ms 127364 KB Output is correct
13 Correct 51 ms 127392 KB Output is correct
14 Correct 50 ms 127352 KB Output is correct
15 Correct 52 ms 127400 KB Output is correct
16 Correct 51 ms 127408 KB Output is correct
17 Correct 52 ms 127352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 127308 KB Output is correct
2 Correct 50 ms 127364 KB Output is correct
3 Correct 52 ms 127328 KB Output is correct
4 Correct 53 ms 127364 KB Output is correct
5 Correct 50 ms 127344 KB Output is correct
6 Correct 50 ms 127316 KB Output is correct
7 Correct 53 ms 127336 KB Output is correct
8 Correct 51 ms 127376 KB Output is correct
9 Correct 50 ms 127344 KB Output is correct
10 Correct 51 ms 127408 KB Output is correct
11 Correct 50 ms 127344 KB Output is correct
12 Correct 52 ms 127364 KB Output is correct
13 Correct 51 ms 127392 KB Output is correct
14 Correct 50 ms 127352 KB Output is correct
15 Correct 52 ms 127400 KB Output is correct
16 Correct 51 ms 127408 KB Output is correct
17 Correct 52 ms 127352 KB Output is correct
18 Correct 51 ms 127308 KB Output is correct
19 Correct 51 ms 127408 KB Output is correct
20 Correct 55 ms 127432 KB Output is correct
21 Correct 53 ms 127384 KB Output is correct
22 Correct 50 ms 127316 KB Output is correct
23 Correct 53 ms 127316 KB Output is correct
24 Correct 49 ms 127308 KB Output is correct
25 Correct 50 ms 127408 KB Output is correct
26 Correct 51 ms 127348 KB Output is correct
27 Correct 49 ms 127412 KB Output is correct
28 Correct 49 ms 127308 KB Output is correct
29 Correct 53 ms 127380 KB Output is correct
30 Correct 51 ms 127340 KB Output is correct
31 Correct 50 ms 127364 KB Output is correct
32 Correct 51 ms 127308 KB Output is correct
33 Correct 52 ms 127344 KB Output is correct
34 Correct 51 ms 127348 KB Output is correct
35 Correct 54 ms 127344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 127308 KB Output is correct
2 Correct 50 ms 127364 KB Output is correct
3 Correct 52 ms 127328 KB Output is correct
4 Correct 53 ms 127364 KB Output is correct
5 Correct 50 ms 127344 KB Output is correct
6 Correct 50 ms 127316 KB Output is correct
7 Correct 53 ms 127336 KB Output is correct
8 Correct 51 ms 127376 KB Output is correct
9 Correct 50 ms 127344 KB Output is correct
10 Correct 51 ms 127408 KB Output is correct
11 Correct 50 ms 127344 KB Output is correct
12 Correct 52 ms 127364 KB Output is correct
13 Correct 51 ms 127392 KB Output is correct
14 Correct 50 ms 127352 KB Output is correct
15 Correct 52 ms 127400 KB Output is correct
16 Correct 51 ms 127408 KB Output is correct
17 Correct 52 ms 127352 KB Output is correct
18 Correct 64 ms 127308 KB Output is correct
19 Correct 58 ms 127360 KB Output is correct
20 Correct 54 ms 127428 KB Output is correct
21 Correct 57 ms 127308 KB Output is correct
22 Correct 65 ms 127564 KB Output is correct
23 Correct 54 ms 127352 KB Output is correct
24 Incorrect 52 ms 127372 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 51 ms 127308 KB Output is correct
2 Correct 50 ms 127364 KB Output is correct
3 Correct 52 ms 127328 KB Output is correct
4 Correct 53 ms 127364 KB Output is correct
5 Correct 50 ms 127344 KB Output is correct
6 Correct 50 ms 127316 KB Output is correct
7 Correct 53 ms 127336 KB Output is correct
8 Correct 51 ms 127376 KB Output is correct
9 Correct 50 ms 127344 KB Output is correct
10 Correct 51 ms 127408 KB Output is correct
11 Correct 50 ms 127344 KB Output is correct
12 Correct 52 ms 127364 KB Output is correct
13 Correct 51 ms 127392 KB Output is correct
14 Correct 50 ms 127352 KB Output is correct
15 Correct 52 ms 127400 KB Output is correct
16 Correct 51 ms 127408 KB Output is correct
17 Correct 52 ms 127352 KB Output is correct
18 Correct 51 ms 127308 KB Output is correct
19 Correct 51 ms 127408 KB Output is correct
20 Correct 55 ms 127432 KB Output is correct
21 Correct 53 ms 127384 KB Output is correct
22 Correct 50 ms 127316 KB Output is correct
23 Correct 53 ms 127316 KB Output is correct
24 Correct 49 ms 127308 KB Output is correct
25 Correct 50 ms 127408 KB Output is correct
26 Correct 51 ms 127348 KB Output is correct
27 Correct 49 ms 127412 KB Output is correct
28 Correct 49 ms 127308 KB Output is correct
29 Correct 53 ms 127380 KB Output is correct
30 Correct 51 ms 127340 KB Output is correct
31 Correct 50 ms 127364 KB Output is correct
32 Correct 51 ms 127308 KB Output is correct
33 Correct 52 ms 127344 KB Output is correct
34 Correct 51 ms 127348 KB Output is correct
35 Correct 54 ms 127344 KB Output is correct
36 Correct 64 ms 127308 KB Output is correct
37 Correct 58 ms 127360 KB Output is correct
38 Correct 54 ms 127428 KB Output is correct
39 Correct 57 ms 127308 KB Output is correct
40 Correct 65 ms 127564 KB Output is correct
41 Correct 54 ms 127352 KB Output is correct
42 Incorrect 52 ms 127372 KB Output isn't correct
43 Halted 0 ms 0 KB -