Submission #224069

# Submission time Handle Problem Language Result Execution time Memory
224069 2020-04-17T07:15:13 Z lyc Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
97 ms 34680 KB
#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)

const int MX_N = 205;
const int MX_T = 1e9+5;

int N, L;
int X[MX_N], T[MX_N];

int atL[MX_N][MX_N][MX_N];
int atR[MX_N][MX_N][MX_N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> L;
    FOR(i,1,N){
        cin >> X[i];
    }
    FOR(i,1,N){
        cin >> T[i];
    }

    X[0] = 0; X[N+1] = L;
    T[0] = T[N+1] = -1;
    //atL[N+1][0][0] = atR[N+1][0][0] = 0;
    FOR(l,1,N+1){
        FOR(r,0,l-1){
            atL[l][r][0] = min(1LL*MX_T, 2LL*X[r] + L-X[l]);
            atR[l][r][0] = min(1LL*MX_T, 2LL*(L-X[l]) + X[r]);
        }
    }

    int ans = 0;
    FOR(y,1,N){
        FOR(r,0,N){
            int mn1 = 2*MX_T, mn2 = 2*MX_T;
            RFOR(l,N+1,r+1){
                atL[l][r][y] = MX_T;
                if (l < N+1) mn1 = min(mn1, atL[l+1][r][y-1]+X[l+1]);
                if (l < N+1) mn2 = min(mn2, atR[l+1][r][y-1]+L+X[r]);
                if (mn1-X[l] <= T[l]) atL[l][r][y] = min(atL[l][r][y], mn1 - X[l]);
                if (mn2-X[l] <= T[l]) atL[l][r][y] = min(atL[l][r][y], mn2 - X[l]);
                //FOR(k,l+1,N+1){
                //    if (atL[k][r][y-1] + X[k]-X[l] <= T[l]) atL[l][r][y] = min(atL[l][r][y], atL[k][r][y-1] + X[k]-X[l]);
                //    if (atR[k][r][y-1] + L-X[l]+X[r] <= T[l]) atL[l][r][y] = min(atL[l][r][y], atR[k][r][y-1] + L-X[l]+X[r]);
                //}
                if (atL[l][r][y] < MX_T) ans = max(ans,y);
            }
        }
        FOR(l,1,N+1){
            int mn1 = 2*MX_T, mn2 = 2*MX_T;
            FOR(r,0,l-1){
                atR[l][r][y] = MX_T;
                if (r > 0) mn1 = min(mn1, atR[l][r-1][y-1]-X[r-1]);
                if (r > 0) mn2 = min(mn2, atL[l][r-1][y-1]+L-X[l]);
                if (mn1+X[r] <= T[r]) atR[l][r][y] = min(atR[l][r][y], mn1+X[r]);
                if (mn2+X[r] <= T[r]) atR[l][r][y] = min(atR[l][r][y], mn2+X[r]);
                //FOR(k,0,r-1){
                //    if (atR[l][k][y-1] + X[r]-X[k] <= T[r]) atR[l][r][y] = min(atR[l][r][y], atR[l][k][y-1] + X[r]-X[k]);
                //    if (atL[l][k][y-1] + X[r]+L-X[l] <= T[r]) atR[l][r][y] = min(atR[l][r][y], atL[l][k][y-1] + X[r]+L-X[l]);
                //}
                if (atR[l][r][y] < MX_T) ans = max(ans,y);
            }
        }
        //TRACE(l _ r _ y _ atL[l][r][y] _ atR[l][r][y]);
        //cout << flush;
        //assert(atL[l][r][y] >= 0 && atR[l][r][y] >= 0);
    }
    cout << ans << '\n';
}

# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Correct 5 ms 640 KB Output is correct
19 Correct 5 ms 512 KB Output is correct
20 Correct 5 ms 512 KB Output is correct
21 Correct 5 ms 640 KB Output is correct
22 Correct 5 ms 512 KB Output is correct
23 Correct 5 ms 640 KB Output is correct
24 Correct 5 ms 640 KB Output is correct
25 Correct 5 ms 640 KB Output is correct
26 Correct 5 ms 640 KB Output is correct
27 Correct 5 ms 512 KB Output is correct
28 Correct 5 ms 512 KB Output is correct
29 Correct 5 ms 640 KB Output is correct
30 Correct 5 ms 640 KB Output is correct
31 Correct 5 ms 640 KB Output is correct
32 Correct 5 ms 640 KB Output is correct
33 Correct 5 ms 640 KB Output is correct
34 Correct 5 ms 640 KB Output is correct
35 Correct 5 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Correct 71 ms 27896 KB Output is correct
19 Correct 39 ms 17408 KB Output is correct
20 Correct 17 ms 9600 KB Output is correct
21 Correct 33 ms 16384 KB Output is correct
22 Correct 45 ms 20984 KB Output is correct
23 Correct 15 ms 8192 KB Output is correct
24 Correct 13 ms 6528 KB Output is correct
25 Correct 14 ms 8064 KB Output is correct
26 Correct 7 ms 3456 KB Output is correct
27 Correct 17 ms 8448 KB Output is correct
28 Correct 11 ms 6144 KB Output is correct
29 Correct 16 ms 8576 KB Output is correct
30 Correct 12 ms 6784 KB Output is correct
31 Correct 16 ms 8056 KB Output is correct
32 Correct 8 ms 4480 KB Output is correct
33 Correct 14 ms 8064 KB Output is correct
34 Correct 6 ms 3200 KB Output is correct
35 Correct 14 ms 7936 KB Output is correct
36 Correct 7 ms 4096 KB Output is correct
37 Correct 15 ms 8448 KB Output is correct
38 Correct 11 ms 4992 KB Output is correct
39 Correct 15 ms 8704 KB Output is correct
40 Correct 9 ms 5376 KB Output is correct
41 Correct 90 ms 34296 KB Output is correct
42 Correct 52 ms 23416 KB Output is correct
43 Correct 94 ms 34296 KB Output is correct
44 Correct 52 ms 23032 KB Output is correct
45 Correct 91 ms 34296 KB Output is correct
46 Correct 49 ms 23416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 6 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 512 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Correct 5 ms 640 KB Output is correct
19 Correct 5 ms 512 KB Output is correct
20 Correct 5 ms 512 KB Output is correct
21 Correct 5 ms 640 KB Output is correct
22 Correct 5 ms 512 KB Output is correct
23 Correct 5 ms 640 KB Output is correct
24 Correct 5 ms 640 KB Output is correct
25 Correct 5 ms 640 KB Output is correct
26 Correct 5 ms 640 KB Output is correct
27 Correct 5 ms 512 KB Output is correct
28 Correct 5 ms 512 KB Output is correct
29 Correct 5 ms 640 KB Output is correct
30 Correct 5 ms 640 KB Output is correct
31 Correct 5 ms 640 KB Output is correct
32 Correct 5 ms 640 KB Output is correct
33 Correct 5 ms 640 KB Output is correct
34 Correct 5 ms 640 KB Output is correct
35 Correct 5 ms 640 KB Output is correct
36 Correct 71 ms 27896 KB Output is correct
37 Correct 39 ms 17408 KB Output is correct
38 Correct 17 ms 9600 KB Output is correct
39 Correct 33 ms 16384 KB Output is correct
40 Correct 45 ms 20984 KB Output is correct
41 Correct 15 ms 8192 KB Output is correct
42 Correct 13 ms 6528 KB Output is correct
43 Correct 14 ms 8064 KB Output is correct
44 Correct 7 ms 3456 KB Output is correct
45 Correct 17 ms 8448 KB Output is correct
46 Correct 11 ms 6144 KB Output is correct
47 Correct 16 ms 8576 KB Output is correct
48 Correct 12 ms 6784 KB Output is correct
49 Correct 16 ms 8056 KB Output is correct
50 Correct 8 ms 4480 KB Output is correct
51 Correct 14 ms 8064 KB Output is correct
52 Correct 6 ms 3200 KB Output is correct
53 Correct 14 ms 7936 KB Output is correct
54 Correct 7 ms 4096 KB Output is correct
55 Correct 15 ms 8448 KB Output is correct
56 Correct 11 ms 4992 KB Output is correct
57 Correct 15 ms 8704 KB Output is correct
58 Correct 9 ms 5376 KB Output is correct
59 Correct 90 ms 34296 KB Output is correct
60 Correct 52 ms 23416 KB Output is correct
61 Correct 94 ms 34296 KB Output is correct
62 Correct 52 ms 23032 KB Output is correct
63 Correct 91 ms 34296 KB Output is correct
64 Correct 49 ms 23416 KB Output is correct
65 Correct 76 ms 30976 KB Output is correct
66 Correct 70 ms 28536 KB Output is correct
67 Correct 71 ms 27384 KB Output is correct
68 Correct 58 ms 25336 KB Output is correct
69 Correct 79 ms 30712 KB Output is correct
70 Correct 76 ms 29432 KB Output is correct
71 Correct 74 ms 29816 KB Output is correct
72 Correct 78 ms 30072 KB Output is correct
73 Correct 67 ms 28120 KB Output is correct
74 Correct 64 ms 26232 KB Output is correct
75 Correct 67 ms 28860 KB Output is correct
76 Correct 89 ms 32888 KB Output is correct
77 Correct 84 ms 33016 KB Output is correct
78 Correct 60 ms 25592 KB Output is correct
79 Correct 60 ms 26488 KB Output is correct
80 Correct 84 ms 32376 KB Output is correct
81 Correct 61 ms 26744 KB Output is correct
82 Correct 66 ms 28296 KB Output is correct
83 Correct 88 ms 34296 KB Output is correct
84 Correct 71 ms 29432 KB Output is correct
85 Correct 79 ms 31992 KB Output is correct
86 Correct 78 ms 31352 KB Output is correct
87 Correct 68 ms 28792 KB Output is correct
88 Correct 95 ms 34552 KB Output is correct
89 Correct 91 ms 34680 KB Output is correct
90 Correct 71 ms 29176 KB Output is correct
91 Correct 97 ms 34552 KB Output is correct
92 Correct 95 ms 34552 KB Output is correct
93 Correct 89 ms 33916 KB Output is correct