Submission #973966

# Submission time Handle Problem Language Result Execution time Memory
973966 2024-05-02T13:56:23 Z Aiperiii Collecting Stamps 3 (JOI20_ho_t3) C++14
100 / 100
84 ms 133360 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int N=205;
int dp[N][N][N][2],a[N],b[N];
signed main(){
    ios_base::sync_with_stdio();
    cin.tie(0);cout.tie(0);
    int n,L;
    cin>>n>>L;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    for(int i=0;i<=n+1;i++){
        for(int j=0;j<=n+1;j++){
            for(int k=0;k<=n;k++){
                dp[i][j][k][0]=1e18;
                dp[i][j][k][1]=1e18;
            }
        }
    }
    a[n+1]=L;
    dp[0][n+1][0][0]=0;
    dp[0][n+1][0][1]=0;
    for(int l=0;l<=n;l++){
        for(int r=n+1;r>l;r--){
            for(int k=0;k<=n;k++){
                int x=dp[l][r][k][0]+a[l+1]-a[l];
                if(x<=b[l+1])dp[l+1][r][k+1][0]=min(dp[l+1][r][k+1][0],x);
                else dp[l+1][r][k][0]=min(dp[l+1][r][k][0],x);
                
                x=dp[l][r][k][1]+L-(a[r]-a[l+1]);
                if(x<=b[l+1])dp[l+1][r][k+1][0]=min(dp[l+1][r][k+1][0],x);
                else dp[l+1][r][k][0]=min(dp[l+1][r][k][0],x);
                
                x=dp[l][r][k][1]+a[r]-a[r-1];
                if(x<=b[r-1])dp[l][r-1][k+1][1]=min(dp[l][r-1][k+1][1],x);
                else dp[l][r-1][k][1]=min(dp[l][r-1][k][1],x);
                
                x=dp[l][r][k][0]+L-(a[r-1]-a[l]);
                if(x<=b[r-1])dp[l][r-1][k+1][1]=min(dp[l][r-1][k+1][1],x);
                else dp[l][r-1][k][1]=min(dp[l][r-1][k][1],x);
            }
        }
    }
    int ans=0;
    for(int l=0;l<=n;l++){
        for(int r=n+1;r>l;r--){
            for(int k=0;k<=n;k++){
                if(dp[l][r][k][0]!=1e18)ans=max(ans,k);
                if(dp[l][r][k][1]!=1e18)ans=max(ans,k);
            }
        }
    }
    cout<<ans<<"\n";
}
/*

*/



# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 2 ms 10900 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8632 KB Output is correct
9 Correct 2 ms 10588 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 10584 KB Output is correct
13 Correct 2 ms 10588 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6488 KB Output is correct
16 Correct 1 ms 10588 KB Output is correct
17 Correct 2 ms 10588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 2 ms 10900 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8632 KB Output is correct
9 Correct 2 ms 10588 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 10584 KB Output is correct
13 Correct 2 ms 10588 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6488 KB Output is correct
16 Correct 1 ms 10588 KB Output is correct
17 Correct 2 ms 10588 KB Output is correct
18 Correct 2 ms 10588 KB Output is correct
19 Correct 1 ms 8540 KB Output is correct
20 Correct 2 ms 10584 KB Output is correct
21 Correct 2 ms 10588 KB Output is correct
22 Correct 1 ms 8540 KB Output is correct
23 Correct 2 ms 12636 KB Output is correct
24 Correct 1 ms 10584 KB Output is correct
25 Correct 2 ms 10588 KB Output is correct
26 Correct 2 ms 10688 KB Output is correct
27 Correct 1 ms 6488 KB Output is correct
28 Correct 1 ms 8536 KB Output is correct
29 Correct 2 ms 12636 KB Output is correct
30 Correct 2 ms 12636 KB Output is correct
31 Correct 2 ms 10588 KB Output is correct
32 Correct 2 ms 10588 KB Output is correct
33 Correct 2 ms 12636 KB Output is correct
34 Correct 2 ms 12636 KB Output is correct
35 Correct 2 ms 12632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 2 ms 10900 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8632 KB Output is correct
9 Correct 2 ms 10588 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 10584 KB Output is correct
13 Correct 2 ms 10588 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6488 KB Output is correct
16 Correct 1 ms 10588 KB Output is correct
17 Correct 2 ms 10588 KB Output is correct
18 Correct 84 ms 119480 KB Output is correct
19 Correct 26 ms 94808 KB Output is correct
20 Correct 14 ms 68188 KB Output is correct
21 Correct 25 ms 90848 KB Output is correct
22 Correct 31 ms 103212 KB Output is correct
23 Correct 12 ms 64092 KB Output is correct
24 Correct 10 ms 55900 KB Output is correct
25 Correct 12 ms 62116 KB Output is correct
26 Correct 6 ms 39516 KB Output is correct
27 Correct 12 ms 64088 KB Output is correct
28 Correct 10 ms 53852 KB Output is correct
29 Correct 13 ms 64092 KB Output is correct
30 Correct 10 ms 57948 KB Output is correct
31 Correct 14 ms 62188 KB Output is correct
32 Correct 8 ms 45660 KB Output is correct
33 Correct 12 ms 62044 KB Output is correct
34 Correct 5 ms 37468 KB Output is correct
35 Correct 12 ms 62044 KB Output is correct
36 Correct 7 ms 43612 KB Output is correct
37 Correct 12 ms 64228 KB Output is correct
38 Correct 7 ms 47708 KB Output is correct
39 Correct 13 ms 66268 KB Output is correct
40 Correct 9 ms 49752 KB Output is correct
41 Correct 58 ms 132540 KB Output is correct
42 Correct 34 ms 109380 KB Output is correct
43 Correct 59 ms 132408 KB Output is correct
44 Correct 35 ms 109144 KB Output is correct
45 Correct 55 ms 132588 KB Output is correct
46 Correct 36 ms 109144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4540 KB Output is correct
3 Correct 1 ms 8540 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 2 ms 10900 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8632 KB Output is correct
9 Correct 2 ms 10588 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 10584 KB Output is correct
13 Correct 2 ms 10588 KB Output is correct
14 Correct 1 ms 6492 KB Output is correct
15 Correct 1 ms 6488 KB Output is correct
16 Correct 1 ms 10588 KB Output is correct
17 Correct 2 ms 10588 KB Output is correct
18 Correct 2 ms 10588 KB Output is correct
19 Correct 1 ms 8540 KB Output is correct
20 Correct 2 ms 10584 KB Output is correct
21 Correct 2 ms 10588 KB Output is correct
22 Correct 1 ms 8540 KB Output is correct
23 Correct 2 ms 12636 KB Output is correct
24 Correct 1 ms 10584 KB Output is correct
25 Correct 2 ms 10588 KB Output is correct
26 Correct 2 ms 10688 KB Output is correct
27 Correct 1 ms 6488 KB Output is correct
28 Correct 1 ms 8536 KB Output is correct
29 Correct 2 ms 12636 KB Output is correct
30 Correct 2 ms 12636 KB Output is correct
31 Correct 2 ms 10588 KB Output is correct
32 Correct 2 ms 10588 KB Output is correct
33 Correct 2 ms 12636 KB Output is correct
34 Correct 2 ms 12636 KB Output is correct
35 Correct 2 ms 12632 KB Output is correct
36 Correct 84 ms 119480 KB Output is correct
37 Correct 26 ms 94808 KB Output is correct
38 Correct 14 ms 68188 KB Output is correct
39 Correct 25 ms 90848 KB Output is correct
40 Correct 31 ms 103212 KB Output is correct
41 Correct 12 ms 64092 KB Output is correct
42 Correct 10 ms 55900 KB Output is correct
43 Correct 12 ms 62116 KB Output is correct
44 Correct 6 ms 39516 KB Output is correct
45 Correct 12 ms 64088 KB Output is correct
46 Correct 10 ms 53852 KB Output is correct
47 Correct 13 ms 64092 KB Output is correct
48 Correct 10 ms 57948 KB Output is correct
49 Correct 14 ms 62188 KB Output is correct
50 Correct 8 ms 45660 KB Output is correct
51 Correct 12 ms 62044 KB Output is correct
52 Correct 5 ms 37468 KB Output is correct
53 Correct 12 ms 62044 KB Output is correct
54 Correct 7 ms 43612 KB Output is correct
55 Correct 12 ms 64228 KB Output is correct
56 Correct 7 ms 47708 KB Output is correct
57 Correct 13 ms 66268 KB Output is correct
58 Correct 9 ms 49752 KB Output is correct
59 Correct 58 ms 132540 KB Output is correct
60 Correct 34 ms 109380 KB Output is correct
61 Correct 59 ms 132408 KB Output is correct
62 Correct 35 ms 109144 KB Output is correct
63 Correct 55 ms 132588 KB Output is correct
64 Correct 36 ms 109144 KB Output is correct
65 Correct 48 ms 127836 KB Output is correct
66 Correct 47 ms 121436 KB Output is correct
67 Correct 45 ms 119388 KB Output is correct
68 Correct 40 ms 115528 KB Output is correct
69 Correct 47 ms 125788 KB Output is correct
70 Correct 47 ms 123736 KB Output is correct
71 Correct 46 ms 123736 KB Output is correct
72 Correct 48 ms 125788 KB Output is correct
73 Correct 43 ms 119388 KB Output is correct
74 Correct 44 ms 115476 KB Output is correct
75 Correct 44 ms 121436 KB Output is correct
76 Correct 52 ms 129872 KB Output is correct
77 Correct 54 ms 129872 KB Output is correct
78 Correct 40 ms 115436 KB Output is correct
79 Correct 40 ms 117336 KB Output is correct
80 Correct 52 ms 128348 KB Output is correct
81 Correct 41 ms 117328 KB Output is correct
82 Correct 48 ms 121624 KB Output is correct
83 Correct 61 ms 132436 KB Output is correct
84 Correct 45 ms 123736 KB Output is correct
85 Correct 50 ms 128076 KB Output is correct
86 Correct 47 ms 127832 KB Output is correct
87 Correct 43 ms 121436 KB Output is correct
88 Correct 64 ms 133360 KB Output is correct
89 Correct 56 ms 133200 KB Output is correct
90 Correct 44 ms 123500 KB Output is correct
91 Correct 57 ms 133204 KB Output is correct
92 Correct 55 ms 133212 KB Output is correct
93 Correct 57 ms 131672 KB Output is correct