Submission #702218

# Submission time Handle Problem Language Result Execution time Memory
702218 2023-02-23T10:27:31 Z huomark1001 Collecting Stamps 3 (JOI20_ho_t3) C++17
0 / 100
1 ms 980 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+1;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]+d[j+1]-d[j]<=t[j+1])][0]=min(dp[i][j+1][k+(dp[i][j][k][1]+d[j+1]-d[j]<=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]+d[j+1]-d[j]<=t[j+1])][0]<lar) ans=max(ans,k+(dp[i][j][k][1]+d[j+1]-d[j]<=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 1 ms 468 KB Output is correct
3 Correct 1 ms 708 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 980 KB Output is correct
7 Incorrect 1 ms 596 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 708 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 980 KB Output is correct
7 Incorrect 1 ms 596 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 708 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 980 KB Output is correct
7 Incorrect 1 ms 596 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 708 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 980 KB Output is correct
7 Incorrect 1 ms 596 KB Output isn't correct
8 Halted 0 ms 0 KB -