Submission #702253

# Submission time Handle Problem Language Result Execution time Memory
702253 2023-02-23T11:42:22 Z Aestivate Collecting Stamps 3 (JOI20_ho_t3) C++17
100 / 100
136 ms 195592 KB
#include<bits/stdc++.h>
#include<random>
 
using namespace std;
 
template<typename T> void _do(T x){cerr<<x<<"\n";}
template<typename T,typename ...U> void _do(T x,U ...y){cerr<<x<<", ";_do(y...);}
#define dbg(...) cerr<<#__VA_ARGS__<<" = ";_do(__VA_ARGS__);
 
#define ss(n) fixed<<setprecision(n)
#define ll long long
#define int ll
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define rep(i,a) for(int i=1;i<=a;i++)
#define rep0(i,a) for(int i=0;i<a;i++)
#define F first
#define S second
#define float double
 
ll gcd(ll a,ll b){if(b==0) return a; return gcd(b,a%b);}
 
const ld pi=3.14159265358979323846264338327950288419716939931;
const int lar=3e18;
const int mol1=1e9+7;
const int mol2=998224353;
const int mol3=1e15+9;
const int bb=137;
int dp[205][205][205][3];
void solve()
{
    int n,l;
    cin>>n>>l;
    int d[n+1]={0},t[n+1]={0},pd[n+1]={0},pt[n+1]={0};
    rep(i,n) cin>>d[i];
    rep(i,n) cin>>t[i];
    for(int i=1;i<=n;i++){
        pd[i]=l-d[n+1-i];
        pt[i]=t[n+1-i];
    }
    
    d[0]=0,t[0]=0;
    rep0(i,n+1) {
        rep0(j,n+1){
            rep0(k,n+1){
                dp[i][j][k][0]=lar+2;
                dp[i][j][k][1]=lar+2;
            }
        }
    }
    int ans=0;
    dp[0][0][0][0]=0;
    dp[0][0][0][1]=0;
    rep0(i,n+1){
        rep0(j,n+1){
            if(i+j>n-1) break;
            for(int k=0;k<=i+j;k++){
                if(dp[i][j][k][0]<lar){
                    dp[i][j+1][k+(dp[i][j][k][0]+d[j+1]-d[j]<=t[j+1])][0]=min(dp[i][j+1][k+(dp[i][j][k][0]+d[j+1]-d[j]<=t[j+1])][0],dp[i][j][k][0]+d[j+1]-d[j]);
                    dp[i+1][j][k+(dp[i][j][k][0]+pd[i+1]+d[j]<=pt[i+1])][1]=min(dp[i+1][j][k+(dp[i][j][k][0]+pd[i+1]+d[j]<=pt[i+1])][1],dp[i][j][k][0]+pd[i+1]+d[j]);
                    if(dp[i][j+1][k+(dp[i][j][k][0]+d[j+1]-d[j]<=t[j+1])][0]<lar) {
                        ans=max(ans,k+(dp[i][j][k][0]+d[j+1]-d[j]<=t[j+1]));
                    }
                    if(dp[i+1][j][k+(dp[i][j][k][0]+pd[i+1]+d[j]<=pt[i+1])][1]<lar) ans=max(ans,k+(dp[i][j][k][0]+pd[i+1]+d[j]<=pt[i+1]));
                
                }
                if(dp[i][j][k][1]<lar){
                    dp[i][j+1][k+(dp[i][j][k][1]+pd[i]+d[j+1]<=t[j+1])][0]=min(dp[i][j+1][k+(dp[i][j][k][1]+pd[i]+d[j+1]<=t[j+1])][0],dp[i][j][k][1]+pd[i]+d[j+1]);
                    dp[i+1][j][k+(dp[i][j][k][1]+pd[i+1]-pd[i]<=pt[i+1])][1]=min(dp[i+1][j][k+(dp[i][j][k][1]+pd[i+1]-pd[i]<=pt[i+1])][1],dp[i][j][k][1]+pd[i+1]-pd[i]);
                    if(dp[i][j+1][k+(dp[i][j][k][1]+pd[i]+d[j+1]<=t[j+1])][0]<lar) ans=max(ans,k+(dp[i][j][k][1]+pd[i]+d[j+1]<=t[j+1]));
                    if(dp[i+1][j][k+(dp[i][j][k][1]+pd[i+1]-pd[i]<=pt[i+1])][1]<lar) ans=max(ans,k+(dp[i][j][k][1]+pd[i+1]-pd[i]<=pt[i+1]));
                }
            }
        }
    }
    cout<<ans<<"\n";
}
 
signed main()
{
    IO
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 964 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 968 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 964 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 968 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 972 KB Output is correct
18 Correct 1 ms 1236 KB Output is correct
19 Correct 1 ms 832 KB Output is correct
20 Correct 1 ms 980 KB Output is correct
21 Correct 1 ms 1320 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 1364 KB Output is correct
24 Correct 1 ms 1092 KB Output is correct
25 Correct 1 ms 1224 KB Output is correct
26 Correct 1 ms 1236 KB Output is correct
27 Correct 1 ms 588 KB Output is correct
28 Correct 1 ms 724 KB Output is correct
29 Correct 1 ms 1364 KB Output is correct
30 Correct 1 ms 1364 KB Output is correct
31 Correct 1 ms 1236 KB Output is correct
32 Correct 1 ms 1108 KB Output is correct
33 Correct 1 ms 1364 KB Output is correct
34 Correct 1 ms 1364 KB Output is correct
35 Correct 1 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 964 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 968 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 972 KB Output is correct
18 Correct 91 ms 156816 KB Output is correct
19 Correct 54 ms 95088 KB Output is correct
20 Correct 27 ms 50540 KB Output is correct
21 Correct 51 ms 89756 KB Output is correct
22 Correct 68 ms 116468 KB Output is correct
23 Correct 25 ms 43168 KB Output is correct
24 Correct 15 ms 33620 KB Output is correct
25 Correct 22 ms 42116 KB Output is correct
26 Correct 8 ms 15956 KB Output is correct
27 Correct 23 ms 43988 KB Output is correct
28 Correct 15 ms 31276 KB Output is correct
29 Correct 24 ms 44872 KB Output is correct
30 Correct 16 ms 35288 KB Output is correct
31 Correct 22 ms 42088 KB Output is correct
32 Correct 11 ms 22056 KB Output is correct
33 Correct 21 ms 42180 KB Output is correct
34 Correct 6 ms 14932 KB Output is correct
35 Correct 18 ms 41288 KB Output is correct
36 Correct 9 ms 19500 KB Output is correct
37 Correct 19 ms 43988 KB Output is correct
38 Correct 12 ms 24020 KB Output is correct
39 Correct 22 ms 45856 KB Output is correct
40 Correct 13 ms 26764 KB Output is correct
41 Correct 128 ms 193588 KB Output is correct
42 Correct 58 ms 130336 KB Output is correct
43 Correct 124 ms 193696 KB Output is correct
44 Correct 54 ms 128716 KB Output is correct
45 Correct 134 ms 193640 KB Output is correct
46 Correct 55 ms 130252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 0 ms 468 KB Output is correct
3 Correct 1 ms 724 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 964 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 968 KB Output is correct
13 Correct 1 ms 980 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 1 ms 980 KB Output is correct
17 Correct 1 ms 972 KB Output is correct
18 Correct 1 ms 1236 KB Output is correct
19 Correct 1 ms 832 KB Output is correct
20 Correct 1 ms 980 KB Output is correct
21 Correct 1 ms 1320 KB Output is correct
22 Correct 1 ms 724 KB Output is correct
23 Correct 1 ms 1364 KB Output is correct
24 Correct 1 ms 1092 KB Output is correct
25 Correct 1 ms 1224 KB Output is correct
26 Correct 1 ms 1236 KB Output is correct
27 Correct 1 ms 588 KB Output is correct
28 Correct 1 ms 724 KB Output is correct
29 Correct 1 ms 1364 KB Output is correct
30 Correct 1 ms 1364 KB Output is correct
31 Correct 1 ms 1236 KB Output is correct
32 Correct 1 ms 1108 KB Output is correct
33 Correct 1 ms 1364 KB Output is correct
34 Correct 1 ms 1364 KB Output is correct
35 Correct 1 ms 1364 KB Output is correct
36 Correct 91 ms 156816 KB Output is correct
37 Correct 54 ms 95088 KB Output is correct
38 Correct 27 ms 50540 KB Output is correct
39 Correct 51 ms 89756 KB Output is correct
40 Correct 68 ms 116468 KB Output is correct
41 Correct 25 ms 43168 KB Output is correct
42 Correct 15 ms 33620 KB Output is correct
43 Correct 22 ms 42116 KB Output is correct
44 Correct 8 ms 15956 KB Output is correct
45 Correct 23 ms 43988 KB Output is correct
46 Correct 15 ms 31276 KB Output is correct
47 Correct 24 ms 44872 KB Output is correct
48 Correct 16 ms 35288 KB Output is correct
49 Correct 22 ms 42088 KB Output is correct
50 Correct 11 ms 22056 KB Output is correct
51 Correct 21 ms 42180 KB Output is correct
52 Correct 6 ms 14932 KB Output is correct
53 Correct 18 ms 41288 KB Output is correct
54 Correct 9 ms 19500 KB Output is correct
55 Correct 19 ms 43988 KB Output is correct
56 Correct 12 ms 24020 KB Output is correct
57 Correct 22 ms 45856 KB Output is correct
58 Correct 13 ms 26764 KB Output is correct
59 Correct 128 ms 193588 KB Output is correct
60 Correct 58 ms 130336 KB Output is correct
61 Correct 124 ms 193696 KB Output is correct
62 Correct 54 ms 128716 KB Output is correct
63 Correct 134 ms 193640 KB Output is correct
64 Correct 55 ms 130252 KB Output is correct
65 Correct 104 ms 174820 KB Output is correct
66 Correct 104 ms 160376 KB Output is correct
67 Correct 92 ms 153412 KB Output is correct
68 Correct 84 ms 141568 KB Output is correct
69 Correct 111 ms 172988 KB Output is correct
70 Correct 110 ms 165692 KB Output is correct
71 Correct 96 ms 167504 KB Output is correct
72 Correct 112 ms 169392 KB Output is correct
73 Correct 82 ms 156928 KB Output is correct
74 Correct 95 ms 146596 KB Output is correct
75 Correct 98 ms 162112 KB Output is correct
76 Correct 121 ms 185976 KB Output is correct
77 Correct 115 ms 186024 KB Output is correct
78 Correct 88 ms 143244 KB Output is correct
79 Correct 90 ms 148300 KB Output is correct
80 Correct 118 ms 182228 KB Output is correct
81 Correct 89 ms 150008 KB Output is correct
82 Correct 83 ms 158676 KB Output is correct
83 Correct 128 ms 193664 KB Output is correct
84 Correct 88 ms 165756 KB Output is correct
85 Correct 97 ms 180364 KB Output is correct
86 Correct 100 ms 176536 KB Output is correct
87 Correct 103 ms 162132 KB Output is correct
88 Correct 136 ms 195496 KB Output is correct
89 Correct 133 ms 195544 KB Output is correct
90 Correct 70 ms 163952 KB Output is correct
91 Correct 135 ms 195592 KB Output is correct
92 Correct 123 ms 195576 KB Output is correct
93 Correct 80 ms 191624 KB Output is correct