Submission #489595

# Submission time Handle Problem Language Result Execution time Memory
489595 2021-11-23T10:21:55 Z bigDuck Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
66 ms 70448 KB
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int n, l, x[201], t[201];

int dp[202][202][202][2];



int32_t main(){
INIT
cin>>n>>l;
for(int i=1; i<=n; i++){
    cin>>x[i];
}
for(int i=1; i<=n; i++){
    cin>>t[i];
}

int res=0;
x[n+1]=l;
for(int cnt=0; cnt<=n; cnt++){
    for(int i=(n+1); i>=1; i--){
        for(int j=0; j<i; j++){

                if( (dp[cnt][i][j][1]!=0)  ){
                    dp[cnt][i][j][0]=(dp[cnt][i][j][0]==0 )?(dp[cnt][i][j][1]+(l-x[i]+x[j]) ):( min(dp[cnt][i][j][0], dp[cnt][i][j][1]+l-x[i]+x[j]) );
                }

            if( (dp[cnt][i][j][0]!=0) || ( (i==(n+1)) && (j==0 ) && (cnt==0) ) ){
                res=max(res, cnt);


                if( (dp[cnt][i][j][0]+x[j+1]-x[j])<=t[j+1] ){
                    dp[cnt+1][i][j+1][0]=(dp[cnt+1][i][j+1][0]==0)?( (dp[cnt][i][j][0]+x[j+1]-x[j]) ):( min((dp[cnt][i][j][0]+x[j+1]-x[j]), dp[cnt+1][i][j+1][0] ) );
                }
                else{
                    dp[cnt][i][j+1][0]=(dp[cnt][i][j+1][0]==0 )?( dp[cnt][i][j][0]+x[j+1]-x[j] ):(min(dp[cnt][i][j+1][0], dp[cnt][i][j][0]+x[j+1]-x[j] ) );
                }
            }


                if(dp[cnt][i][j][0]!=0){
                    dp[cnt][i][j][1]=(dp[cnt][i][j][1]==0 )?(dp[cnt][i][j][0]+l-x[i]+x[j] ):(min(dp[cnt][i][j][1], dp[cnt][i][j][0]+l-x[i]+x[j] ) );
                }

            if( (dp[cnt][i][j][1]!=0) || ( (i==(n+1)) && (j==0) && (cnt==0) )  ){
                res=max(res, cnt);
                if(dp[cnt][i][j][0]!=0){
                    dp[cnt][i][j][1]=(dp[cnt][i][j][1]==0 )?(dp[cnt][i][j][0]+l-x[i]+x[j] ):(min(dp[cnt][i][j][1], dp[cnt][i][j][0]+l-x[i]+x[j] ) );
                }
                if( ( dp[cnt][i][j][1]+x[i]-x[i-1] )<=t[i-1] ){
                    dp[cnt+1][i-1][j][1]=(dp[cnt+1][i-1][j][1]==0 )?(dp[cnt][i][j][1]+x[i]-x[i-1] ):(min(dp[cnt][i][j][1]+x[i]-x[i-1], dp[cnt+1][i-1][j][1] ) );
                }
                else{
                    dp[cnt][i-1][j][1]=(dp[cnt][i-1][j][1]==0)?(dp[cnt][i][j][1]+x[i]-x[i-1] ):(min(dp[cnt][i-1][j][1], dp[cnt][i][j][1]+x[i]-x[i-1]) );
                }
            }


            //cout<<"cnt="<<cnt<<" i="<<i<<" j="<<j<<" dp0="<<dp[cnt][i][j][0]<<" dp1="<<dp[cnt][i][j][1]<<"\n";
        }
    }
}
cout<<res;







return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 0 ms 588 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 0 ms 588 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 588 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 588 KB Output is correct
22 Correct 0 ms 460 KB Output is correct
23 Correct 1 ms 716 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 1 ms 588 KB Output is correct
26 Correct 1 ms 588 KB Output is correct
27 Correct 0 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 844 KB Output is correct
30 Correct 1 ms 716 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 0 ms 332 KB Output is correct
33 Correct 1 ms 716 KB Output is correct
34 Correct 1 ms 716 KB Output is correct
35 Correct 1 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 0 ms 588 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 40 ms 36308 KB Output is correct
19 Correct 29 ms 27308 KB Output is correct
20 Correct 12 ms 12748 KB Output is correct
21 Correct 23 ms 22068 KB Output is correct
22 Correct 31 ms 32292 KB Output is correct
23 Correct 12 ms 14924 KB Output is correct
24 Correct 6 ms 6092 KB Output is correct
25 Correct 11 ms 14668 KB Output is correct
26 Correct 4 ms 3532 KB Output is correct
27 Correct 12 ms 15564 KB Output is correct
28 Correct 6 ms 5944 KB Output is correct
29 Correct 11 ms 13132 KB Output is correct
30 Correct 7 ms 6552 KB Output is correct
31 Correct 10 ms 11916 KB Output is correct
32 Correct 5 ms 6860 KB Output is correct
33 Correct 11 ms 12008 KB Output is correct
34 Correct 3 ms 3660 KB Output is correct
35 Correct 6 ms 3276 KB Output is correct
36 Correct 5 ms 4044 KB Output is correct
37 Correct 7 ms 3564 KB Output is correct
38 Correct 5 ms 5892 KB Output is correct
39 Correct 6 ms 3744 KB Output is correct
40 Correct 5 ms 4684 KB Output is correct
41 Correct 55 ms 56908 KB Output is correct
42 Correct 16 ms 972 KB Output is correct
43 Correct 59 ms 59296 KB Output is correct
44 Correct 17 ms 1032 KB Output is correct
45 Correct 56 ms 58388 KB Output is correct
46 Correct 16 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 460 KB Output is correct
9 Correct 0 ms 588 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 588 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 588 KB Output is correct
22 Correct 0 ms 460 KB Output is correct
23 Correct 1 ms 716 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 1 ms 588 KB Output is correct
26 Correct 1 ms 588 KB Output is correct
27 Correct 0 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 844 KB Output is correct
30 Correct 1 ms 716 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 0 ms 332 KB Output is correct
33 Correct 1 ms 716 KB Output is correct
34 Correct 1 ms 716 KB Output is correct
35 Correct 1 ms 716 KB Output is correct
36 Correct 40 ms 36308 KB Output is correct
37 Correct 29 ms 27308 KB Output is correct
38 Correct 12 ms 12748 KB Output is correct
39 Correct 23 ms 22068 KB Output is correct
40 Correct 31 ms 32292 KB Output is correct
41 Correct 12 ms 14924 KB Output is correct
42 Correct 6 ms 6092 KB Output is correct
43 Correct 11 ms 14668 KB Output is correct
44 Correct 4 ms 3532 KB Output is correct
45 Correct 12 ms 15564 KB Output is correct
46 Correct 6 ms 5944 KB Output is correct
47 Correct 11 ms 13132 KB Output is correct
48 Correct 7 ms 6552 KB Output is correct
49 Correct 10 ms 11916 KB Output is correct
50 Correct 5 ms 6860 KB Output is correct
51 Correct 11 ms 12008 KB Output is correct
52 Correct 3 ms 3660 KB Output is correct
53 Correct 6 ms 3276 KB Output is correct
54 Correct 5 ms 4044 KB Output is correct
55 Correct 7 ms 3564 KB Output is correct
56 Correct 5 ms 5892 KB Output is correct
57 Correct 6 ms 3744 KB Output is correct
58 Correct 5 ms 4684 KB Output is correct
59 Correct 55 ms 56908 KB Output is correct
60 Correct 16 ms 972 KB Output is correct
61 Correct 59 ms 59296 KB Output is correct
62 Correct 17 ms 1032 KB Output is correct
63 Correct 56 ms 58388 KB Output is correct
64 Correct 16 ms 972 KB Output is correct
65 Correct 50 ms 50420 KB Output is correct
66 Correct 44 ms 45416 KB Output is correct
67 Correct 39 ms 36340 KB Output is correct
68 Correct 36 ms 34148 KB Output is correct
69 Correct 49 ms 48616 KB Output is correct
70 Correct 50 ms 56060 KB Output is correct
71 Correct 45 ms 38184 KB Output is correct
72 Correct 55 ms 58056 KB Output is correct
73 Correct 34 ms 27736 KB Output is correct
74 Correct 43 ms 50964 KB Output is correct
75 Correct 50 ms 37316 KB Output is correct
76 Correct 56 ms 50028 KB Output is correct
77 Correct 48 ms 45044 KB Output is correct
78 Correct 37 ms 37068 KB Output is correct
79 Correct 43 ms 42964 KB Output is correct
80 Correct 54 ms 51808 KB Output is correct
81 Correct 46 ms 36260 KB Output is correct
82 Correct 31 ms 22508 KB Output is correct
83 Correct 51 ms 48004 KB Output is correct
84 Correct 32 ms 23108 KB Output is correct
85 Correct 42 ms 36112 KB Output is correct
86 Correct 46 ms 25684 KB Output is correct
87 Correct 44 ms 46172 KB Output is correct
88 Correct 60 ms 67428 KB Output is correct
89 Correct 66 ms 62516 KB Output is correct
90 Correct 24 ms 1168 KB Output is correct
91 Correct 62 ms 70448 KB Output is correct
92 Correct 53 ms 54552 KB Output is correct
93 Correct 25 ms 1096 KB Output is correct