Submission #537262

# Submission time Handle Problem Language Result Execution time Memory
537262 2022-03-14T20:48:46 Z Rafi22 Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
ll mod=1000000007;
int inf=1000000007;
ll infl=1000000000000000007;

const int N=207;

int a[N],t[N];

int DP[N][N][N][2];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,x;
    cin>>n>>x;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>t[i];
    for(int l=0;l<=n;l++)
    {
        for(int r=0;r<=n;r++)
        {
            for(int i=0;i<=n;i++)
            {
                DP[l][r][i][0]=inf;
                DP[l][r][i][1]=inf;
            }
        }
    }
    DP[0][0][0][0]=0;
    for(int l=0;l<=n;l++)
    {
        for(int r=0;r<=n;r++)
        {
            for(int i=0;i<=n;i++)
            {
                int d=DP[l][r][i][0]+a[l+1]-a[l];
                if(d<=t[l+1]) DP[l+1][r][i+1][0]=min(DP[l+1][r][i+1][0],d);
                else DP[l+1][r][i][0]=min(DP[l+1][r][i][0],d);
                d=DP[l][r][i][0]+a[l]+(x-a[n-r])%x;
                if(d<=t[n-r]) DP[l][r+1][i+1][1]=min(DP[l][r+1][i+1][1],d);
                else DP[l][r+1][i][1]=min(DP[l][r+1][i][1],d);
                d=DP[l][r][i][1]+a[n-r+1]-a[n-r];
                if(d<=t[n-r]) DP[l][r+1][i+1][1]=min(DP[l][r+1][i+1][1],d);
                d=DP[l][r][i][1]+(x-a[n-r+1])%x+a[l+1];
                if(d<=t[l+1]) DP[l+1][r][i+1][0]=min(DP[l+1][r][i+1][0],d);
                else DP[l+1][r][i][0]=min(DP[l+1][r][i][0],d);
            }
        }
    }
    int ans=0;
    for(int l=0;l<=n;l++)
    {
        for(int r=0;r<=n;r++)
        {
            if(l+r>n) continue;
            for(int i=0;i<=n;i++)
            {
                if(min(DP[l][r][i][0],DP[l][r][i][1])!=inf) ans=max(ans,i);
            }
        }
    }
    cout<<ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -