Submission #202331

# Submission time Handle Problem Language Result Execution time Memory
202331 2020-02-15T12:24:47 Z giorgikob Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
119 ms 128892 KB
#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
using namespace std;

const int N = 1e6 + 69;

int n,k,l,r,ans;
ll dro,x,L;

ll A[N],T[N];

ll dp[202][202][202][2];

ll dist(ll x,ll y){
    return min(abs(x-y),L-abs(x-y));
}

int main(){

    cin>>n>>L;

    for(int i=1;i<=n;i++){
        cin>>A[i];
    }

    A[n+1] = L;

    for(int i=1;i<=n;i++){
        cin>>T[i];
    }

    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=n;k++){
                for(int t=0;t<=1;t++)
                    dp[i][j][k][t] = 1e18;
            }
        }
    }




    dp[0][0][0][1] = dp[0][0][0][0] = 0;

    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            for(int k=0;k<=i+j;k++){

                x = dp[i][j][k][0];
                if(x<1e18){
                    ans = max(k,ans);
                }

                dro = x + dist(A[i+1], A[i]);
                dp[i+1][j][k+(dro<=T[i+1])][0] = min(dp[i+1][j][k+(dro<=T[i+1])][0],dro);

                dro = x + dist(A[i], A[n-j]);
                dp[i][j+1][k+(dro<=T[n-j])][1] = min(dp[i][j+1][k+(dro<=T[n-j])][1],dro);

                x = dp[i][j][k][1];
                if(x<1e18){
                    ans = max(k,ans);
                }

                dro = x + dist( A[i+1], A[n+1-j]);
                dp[i+1][j][k+(dro<=T[i+1])][0] = min(dp[i+1][j][k+(dro<=T[i+1])][0],dro);

                dro = x + dist(A[n+1-j],A[n-j]);
                dp[i][j+1][k+(dro<=T[n-j])][1] = min(dp[i][j+1][k+(dro<=T[n-j])][1],dro);

            }
        }
    }

    cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 632 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 888 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 888 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 888 KB Output is correct
13 Correct 5 ms 892 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 632 KB Output is correct
16 Correct 5 ms 888 KB Output is correct
17 Correct 5 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 632 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 888 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 888 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 888 KB Output is correct
13 Correct 5 ms 892 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 632 KB Output is correct
16 Correct 5 ms 888 KB Output is correct
17 Correct 5 ms 888 KB Output is correct
18 Correct 5 ms 1144 KB Output is correct
19 Correct 7 ms 760 KB Output is correct
20 Correct 5 ms 888 KB Output is correct
21 Correct 5 ms 1016 KB Output is correct
22 Correct 5 ms 760 KB Output is correct
23 Correct 5 ms 1144 KB Output is correct
24 Correct 6 ms 1016 KB Output is correct
25 Correct 5 ms 1144 KB Output is correct
26 Correct 5 ms 1016 KB Output is correct
27 Correct 5 ms 632 KB Output is correct
28 Correct 5 ms 632 KB Output is correct
29 Correct 5 ms 1144 KB Output is correct
30 Correct 5 ms 1144 KB Output is correct
31 Correct 5 ms 1144 KB Output is correct
32 Correct 5 ms 1020 KB Output is correct
33 Correct 6 ms 1272 KB Output is correct
34 Correct 5 ms 1272 KB Output is correct
35 Correct 5 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 632 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 888 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 888 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 888 KB Output is correct
13 Correct 5 ms 892 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 632 KB Output is correct
16 Correct 5 ms 888 KB Output is correct
17 Correct 5 ms 888 KB Output is correct
18 Correct 94 ms 103416 KB Output is correct
19 Correct 51 ms 62840 KB Output is correct
20 Correct 28 ms 33528 KB Output is correct
21 Correct 53 ms 59256 KB Output is correct
22 Correct 69 ms 77048 KB Output is correct
23 Correct 23 ms 28536 KB Output is correct
24 Correct 19 ms 22392 KB Output is correct
25 Correct 23 ms 28024 KB Output is correct
26 Correct 11 ms 10744 KB Output is correct
27 Correct 24 ms 29176 KB Output is correct
28 Correct 18 ms 20856 KB Output is correct
29 Correct 30 ms 29736 KB Output is correct
30 Correct 19 ms 23416 KB Output is correct
31 Correct 23 ms 28024 KB Output is correct
32 Correct 14 ms 14712 KB Output is correct
33 Correct 24 ms 27896 KB Output is correct
34 Correct 11 ms 10104 KB Output is correct
35 Correct 23 ms 27384 KB Output is correct
36 Correct 12 ms 13048 KB Output is correct
37 Correct 25 ms 29176 KB Output is correct
38 Correct 15 ms 15996 KB Output is correct
39 Correct 25 ms 30328 KB Output is correct
40 Correct 16 ms 17912 KB Output is correct
41 Correct 109 ms 127608 KB Output is correct
42 Correct 69 ms 86008 KB Output is correct
43 Correct 105 ms 127608 KB Output is correct
44 Correct 71 ms 84984 KB Output is correct
45 Correct 106 ms 127608 KB Output is correct
46 Correct 71 ms 86008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 632 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 888 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 760 KB Output is correct
9 Correct 5 ms 888 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 888 KB Output is correct
13 Correct 5 ms 892 KB Output is correct
14 Correct 5 ms 632 KB Output is correct
15 Correct 5 ms 632 KB Output is correct
16 Correct 5 ms 888 KB Output is correct
17 Correct 5 ms 888 KB Output is correct
18 Correct 5 ms 1144 KB Output is correct
19 Correct 7 ms 760 KB Output is correct
20 Correct 5 ms 888 KB Output is correct
21 Correct 5 ms 1016 KB Output is correct
22 Correct 5 ms 760 KB Output is correct
23 Correct 5 ms 1144 KB Output is correct
24 Correct 6 ms 1016 KB Output is correct
25 Correct 5 ms 1144 KB Output is correct
26 Correct 5 ms 1016 KB Output is correct
27 Correct 5 ms 632 KB Output is correct
28 Correct 5 ms 632 KB Output is correct
29 Correct 5 ms 1144 KB Output is correct
30 Correct 5 ms 1144 KB Output is correct
31 Correct 5 ms 1144 KB Output is correct
32 Correct 5 ms 1020 KB Output is correct
33 Correct 6 ms 1272 KB Output is correct
34 Correct 5 ms 1272 KB Output is correct
35 Correct 5 ms 1272 KB Output is correct
36 Correct 94 ms 103416 KB Output is correct
37 Correct 51 ms 62840 KB Output is correct
38 Correct 28 ms 33528 KB Output is correct
39 Correct 53 ms 59256 KB Output is correct
40 Correct 69 ms 77048 KB Output is correct
41 Correct 23 ms 28536 KB Output is correct
42 Correct 19 ms 22392 KB Output is correct
43 Correct 23 ms 28024 KB Output is correct
44 Correct 11 ms 10744 KB Output is correct
45 Correct 24 ms 29176 KB Output is correct
46 Correct 18 ms 20856 KB Output is correct
47 Correct 30 ms 29736 KB Output is correct
48 Correct 19 ms 23416 KB Output is correct
49 Correct 23 ms 28024 KB Output is correct
50 Correct 14 ms 14712 KB Output is correct
51 Correct 24 ms 27896 KB Output is correct
52 Correct 11 ms 10104 KB Output is correct
53 Correct 23 ms 27384 KB Output is correct
54 Correct 12 ms 13048 KB Output is correct
55 Correct 25 ms 29176 KB Output is correct
56 Correct 15 ms 15996 KB Output is correct
57 Correct 25 ms 30328 KB Output is correct
58 Correct 16 ms 17912 KB Output is correct
59 Correct 109 ms 127608 KB Output is correct
60 Correct 69 ms 86008 KB Output is correct
61 Correct 105 ms 127608 KB Output is correct
62 Correct 71 ms 84984 KB Output is correct
63 Correct 106 ms 127608 KB Output is correct
64 Correct 71 ms 86008 KB Output is correct
65 Correct 95 ms 115192 KB Output is correct
66 Correct 88 ms 105848 KB Output is correct
67 Correct 84 ms 101240 KB Output is correct
68 Correct 75 ms 93432 KB Output is correct
69 Correct 94 ms 114040 KB Output is correct
70 Correct 90 ms 109304 KB Output is correct
71 Correct 92 ms 110456 KB Output is correct
72 Correct 96 ms 111608 KB Output is correct
73 Correct 84 ms 103672 KB Output is correct
74 Correct 81 ms 96760 KB Output is correct
75 Correct 87 ms 107000 KB Output is correct
76 Correct 102 ms 122616 KB Output is correct
77 Correct 100 ms 122616 KB Output is correct
78 Correct 78 ms 94584 KB Output is correct
79 Correct 81 ms 97784 KB Output is correct
80 Correct 100 ms 120184 KB Output is correct
81 Correct 80 ms 98920 KB Output is correct
82 Correct 86 ms 104696 KB Output is correct
83 Correct 112 ms 127680 KB Output is correct
84 Correct 106 ms 109304 KB Output is correct
85 Correct 104 ms 118904 KB Output is correct
86 Correct 105 ms 116472 KB Output is correct
87 Correct 90 ms 107000 KB Output is correct
88 Correct 111 ms 128760 KB Output is correct
89 Correct 109 ms 128760 KB Output is correct
90 Correct 92 ms 108152 KB Output is correct
91 Correct 111 ms 128760 KB Output is correct
92 Correct 119 ms 128892 KB Output is correct
93 Correct 108 ms 126424 KB Output is correct