Submission #997580

# Submission time Handle Problem Language Result Execution time Memory
997580 2024-06-12T14:13:07 Z irmuun Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
56 ms 134320 KB
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

//try
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }

ll dpL[205][205][205];
ll dpR[205][205][205];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,L;
    cin>>n>>L;
    ll x[n+5],t[n+5];
    x[0]=0;
    x[n+1]=L;
    for(ll i=1;i<=n;i++){
        cin>>x[i];
    }
    for(ll i=1;i<=n;i++){
        cin>>t[i];
    }
    for(ll i=0;i<=n+1;i++){
        for(ll j=0;j<=n+1;j++){
            for(ll k=0;k<=n;k++){
                dpL[i][j][k]=1e18;
                dpR[i][j][k]=1e18;
            }
        }
    }
    dpL[0][n+1][0]=0;
    dpR[0][n+1][0]=0;
    for(ll i=0;i<=n;i++){
        for(ll j=n+1;j>=i+2;j--){
            for(ll k=0;k<=n;k++){
                ll tm=min(dpL[i][j][k]+x[i+1]-x[i],dpR[i][j][k]+L-(x[j]-x[i+1]));
                chmin(dpL[i+1][j][k+(tm<=t[i+1])],tm);
                tm=min(dpR[i][j][k]+x[j]-x[j-1],dpL[i][j][k]+L-(x[j-1]-x[i]));
                chmin(dpR[i][j-1][k+(tm<=t[j-1])],tm);
            }
        }
    }
    ll ans=0;
    for(ll i=0;i<=n+1;i++){
        for(ll j=0;j<=n+1;j++){
            for(ll k=0;k<=n;k++){
                if(dpL[i][j][k]!=1e18){
                    ans=max(ans,k);
                }
                if(dpR[i][j][k]!=1e18){
                    ans=max(ans,k);
                }
            }
        }
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 10588 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 10588 KB Output is correct
6 Correct 1 ms 12636 KB Output is correct
7 Correct 1 ms 10588 KB Output is correct
8 Correct 1 ms 10588 KB Output is correct
9 Correct 1 ms 12752 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6624 KB Output is correct
12 Correct 1 ms 12636 KB Output is correct
13 Correct 2 ms 12636 KB Output is correct
14 Correct 1 ms 10588 KB Output is correct
15 Correct 1 ms 10588 KB Output is correct
16 Correct 1 ms 12636 KB Output is correct
17 Correct 1 ms 12636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 10588 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 10588 KB Output is correct
6 Correct 1 ms 12636 KB Output is correct
7 Correct 1 ms 10588 KB Output is correct
8 Correct 1 ms 10588 KB Output is correct
9 Correct 1 ms 12752 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6624 KB Output is correct
12 Correct 1 ms 12636 KB Output is correct
13 Correct 2 ms 12636 KB Output is correct
14 Correct 1 ms 10588 KB Output is correct
15 Correct 1 ms 10588 KB Output is correct
16 Correct 1 ms 12636 KB Output is correct
17 Correct 1 ms 12636 KB Output is correct
18 Correct 1 ms 14752 KB Output is correct
19 Correct 1 ms 10588 KB Output is correct
20 Correct 1 ms 12636 KB Output is correct
21 Correct 2 ms 14684 KB Output is correct
22 Correct 1 ms 10588 KB Output is correct
23 Correct 2 ms 14680 KB Output is correct
24 Correct 2 ms 14680 KB Output is correct
25 Correct 1 ms 14684 KB Output is correct
26 Correct 1 ms 14680 KB Output is correct
27 Correct 1 ms 10588 KB Output is correct
28 Correct 1 ms 10588 KB Output is correct
29 Correct 1 ms 14684 KB Output is correct
30 Correct 2 ms 14684 KB Output is correct
31 Correct 1 ms 14684 KB Output is correct
32 Correct 2 ms 14684 KB Output is correct
33 Correct 2 ms 14684 KB Output is correct
34 Correct 1 ms 14684 KB Output is correct
35 Correct 2 ms 14684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 10588 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 10588 KB Output is correct
6 Correct 1 ms 12636 KB Output is correct
7 Correct 1 ms 10588 KB Output is correct
8 Correct 1 ms 10588 KB Output is correct
9 Correct 1 ms 12752 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6624 KB Output is correct
12 Correct 1 ms 12636 KB Output is correct
13 Correct 2 ms 12636 KB Output is correct
14 Correct 1 ms 10588 KB Output is correct
15 Correct 1 ms 10588 KB Output is correct
16 Correct 1 ms 12636 KB Output is correct
17 Correct 1 ms 12636 KB Output is correct
18 Correct 40 ms 121684 KB Output is correct
19 Correct 23 ms 97084 KB Output is correct
20 Correct 13 ms 72284 KB Output is correct
21 Correct 22 ms 92980 KB Output is correct
22 Correct 29 ms 105048 KB Output is correct
23 Correct 11 ms 66140 KB Output is correct
24 Correct 9 ms 60104 KB Output is correct
25 Correct 10 ms 64096 KB Output is correct
26 Correct 5 ms 41564 KB Output is correct
27 Correct 11 ms 68188 KB Output is correct
28 Correct 8 ms 55896 KB Output is correct
29 Correct 11 ms 68212 KB Output is correct
30 Correct 9 ms 59996 KB Output is correct
31 Correct 11 ms 64092 KB Output is correct
32 Correct 6 ms 47708 KB Output is correct
33 Correct 12 ms 64224 KB Output is correct
34 Correct 4 ms 39516 KB Output is correct
35 Correct 10 ms 64092 KB Output is correct
36 Correct 8 ms 45660 KB Output is correct
37 Correct 11 ms 68264 KB Output is correct
38 Correct 7 ms 51804 KB Output is correct
39 Correct 11 ms 68332 KB Output is correct
40 Correct 7 ms 51804 KB Output is correct
41 Correct 54 ms 134004 KB Output is correct
42 Correct 32 ms 113500 KB Output is correct
43 Correct 49 ms 133976 KB Output is correct
44 Correct 42 ms 113752 KB Output is correct
45 Correct 52 ms 133976 KB Output is correct
46 Correct 31 ms 113244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 10588 KB Output is correct
4 Correct 1 ms 8540 KB Output is correct
5 Correct 1 ms 10588 KB Output is correct
6 Correct 1 ms 12636 KB Output is correct
7 Correct 1 ms 10588 KB Output is correct
8 Correct 1 ms 10588 KB Output is correct
9 Correct 1 ms 12752 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6624 KB Output is correct
12 Correct 1 ms 12636 KB Output is correct
13 Correct 2 ms 12636 KB Output is correct
14 Correct 1 ms 10588 KB Output is correct
15 Correct 1 ms 10588 KB Output is correct
16 Correct 1 ms 12636 KB Output is correct
17 Correct 1 ms 12636 KB Output is correct
18 Correct 1 ms 14752 KB Output is correct
19 Correct 1 ms 10588 KB Output is correct
20 Correct 1 ms 12636 KB Output is correct
21 Correct 2 ms 14684 KB Output is correct
22 Correct 1 ms 10588 KB Output is correct
23 Correct 2 ms 14680 KB Output is correct
24 Correct 2 ms 14680 KB Output is correct
25 Correct 1 ms 14684 KB Output is correct
26 Correct 1 ms 14680 KB Output is correct
27 Correct 1 ms 10588 KB Output is correct
28 Correct 1 ms 10588 KB Output is correct
29 Correct 1 ms 14684 KB Output is correct
30 Correct 2 ms 14684 KB Output is correct
31 Correct 1 ms 14684 KB Output is correct
32 Correct 2 ms 14684 KB Output is correct
33 Correct 2 ms 14684 KB Output is correct
34 Correct 1 ms 14684 KB Output is correct
35 Correct 2 ms 14684 KB Output is correct
36 Correct 40 ms 121684 KB Output is correct
37 Correct 23 ms 97084 KB Output is correct
38 Correct 13 ms 72284 KB Output is correct
39 Correct 22 ms 92980 KB Output is correct
40 Correct 29 ms 105048 KB Output is correct
41 Correct 11 ms 66140 KB Output is correct
42 Correct 9 ms 60104 KB Output is correct
43 Correct 10 ms 64096 KB Output is correct
44 Correct 5 ms 41564 KB Output is correct
45 Correct 11 ms 68188 KB Output is correct
46 Correct 8 ms 55896 KB Output is correct
47 Correct 11 ms 68212 KB Output is correct
48 Correct 9 ms 59996 KB Output is correct
49 Correct 11 ms 64092 KB Output is correct
50 Correct 6 ms 47708 KB Output is correct
51 Correct 12 ms 64224 KB Output is correct
52 Correct 4 ms 39516 KB Output is correct
53 Correct 10 ms 64092 KB Output is correct
54 Correct 8 ms 45660 KB Output is correct
55 Correct 11 ms 68264 KB Output is correct
56 Correct 7 ms 51804 KB Output is correct
57 Correct 11 ms 68332 KB Output is correct
58 Correct 7 ms 51804 KB Output is correct
59 Correct 54 ms 134004 KB Output is correct
60 Correct 32 ms 113500 KB Output is correct
61 Correct 49 ms 133976 KB Output is correct
62 Correct 42 ms 113752 KB Output is correct
63 Correct 52 ms 133976 KB Output is correct
64 Correct 31 ms 113244 KB Output is correct
65 Correct 45 ms 129744 KB Output is correct
66 Correct 40 ms 125788 KB Output is correct
67 Correct 37 ms 121692 KB Output is correct
68 Correct 39 ms 117596 KB Output is correct
69 Correct 48 ms 129880 KB Output is correct
70 Correct 42 ms 125788 KB Output is correct
71 Correct 55 ms 125776 KB Output is correct
72 Correct 47 ms 127836 KB Output is correct
73 Correct 39 ms 121692 KB Output is correct
74 Correct 40 ms 117592 KB Output is correct
75 Correct 45 ms 125636 KB Output is correct
76 Correct 48 ms 133980 KB Output is correct
77 Correct 47 ms 133980 KB Output is correct
78 Correct 36 ms 117596 KB Output is correct
79 Correct 39 ms 119628 KB Output is correct
80 Correct 48 ms 133976 KB Output is correct
81 Correct 37 ms 121692 KB Output is correct
82 Correct 53 ms 123740 KB Output is correct
83 Correct 51 ms 133780 KB Output is correct
84 Correct 42 ms 125788 KB Output is correct
85 Correct 47 ms 131928 KB Output is correct
86 Correct 47 ms 129896 KB Output is correct
87 Correct 47 ms 125788 KB Output is correct
88 Correct 52 ms 134232 KB Output is correct
89 Correct 51 ms 134232 KB Output is correct
90 Correct 42 ms 125776 KB Output is correct
91 Correct 53 ms 134224 KB Output is correct
92 Correct 56 ms 134320 KB Output is correct
93 Correct 50 ms 133980 KB Output is correct