Submission #788217

# Submission time Handle Problem Language Result Execution time Memory
788217 2023-07-20T02:14:35 Z vjudge1 Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
1 ms 596 KB
#include<bits/stdc++.h>
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
#define pil pair<int,long long>
const int inf=1e9+2;
int dp[201][201][201][2];
int x[201],t[201],y[201];
int n;
int run(int pos){
if (pos==0)return n;
return pos-1;
}
int nur(int pos){
if (pos==n)return 0;
return pos+1;
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("temp.INP","r",stdin);
    //freopen("temp.OUT","w",stdout);
    long long l;
    cin>>n>>l;
    for1(i,1,n){
    cin>>x[i];
    y[i]=l-x[i];
    }
    for1(i,1,n){
    cin>>t[i];
    }
    for1(i,0,n){
    for1(j,0,n){
    for1(k,0,n){
    dp[i][j][k][0]=dp[i][j][k][1]=inf;
    }
    }
    }
    dp[0][0][0][0]=dp[0][0][0][1]=0;
    //cout<<dp[0][1][2][0]<<'\n';
    for1(i,0,0){
    for1(j,0,n){
    if (i!=0&&i<j)continue;
    for2(k,n,0){
    for1(turn,0,1){
    if (dp[i][j][k][turn]>=inf)continue;
    if (i==j&&i!=0)continue;
    if (j==n)continue;
    if (i==1)continue;
    //cout<<k<<'\n';
    //cout<<i<<" "<<j<<" "<<k<<" "<<turn<<" "<<dp[i][j][k][turn]<<'\n';
    if (turn){
        //on i
        //go i
        int nxt=run(i);
        int newcost=min(inf,dp[i][j][k][turn]+y[nxt]-y[i]);
        int newk=k;
        if (newcost<=t[nxt])newk++;
        dp[nxt][j][newk][1]=min(dp[nxt][j][newk][1],newcost);
        //go j
        nxt=nur(j);
        newcost=min(inf,dp[i][j][k][turn]+y[i]+x[nxt]);
        newk=k;
        if (newcost<=t[nxt])newk++;
        dp[i][nxt][newk][0]=min(dp[i][nxt][newk][0],newcost);
    }
    else {
        //on j
        //go i
        int nxt=run(i);
        int newcost=min(inf,dp[i][j][k][turn]+x[j]+y[nxt]);
        int newk=k;
        if (newcost<=t[nxt])newk++;
        dp[nxt][j][newk][1]=min(dp[nxt][j][newk][1],newcost);
        //go j
        nxt=nur(j);
        newk=k;
        newcost=min(inf,dp[i][j][k][turn]+x[nxt]-x[j]);
        if (newcost<=t[nxt])newk++;
        dp[i][nxt][newk][0]=min(dp[i][nxt][newk][0],newcost);
    }
    }
    }
    }
    }
    //cout<<dp[0][1][2][0];
    for2(i,n,1){
    for1(j,0,n){
    if (i!=0&&i<j)continue;
    for2(k,n,0){
    for1(turn,0,1){
    if (dp[i][j][k][turn]>=inf)continue;
    if (i==j&&i!=0)continue;
    if (j==n)continue;
    if (i==1)continue;
    if (turn){
        //on i
        //go i
        int nxt=run(i);
        int newcost=min(inf,dp[i][j][k][turn]+y[nxt]-y[i]);
        int newk=k;
        if (newcost<=t[nxt])newk++;
        dp[nxt][j][newk][1]=min(dp[nxt][j][newk][1],newcost);
        //go j
        nxt=nur(j);
        newcost=min(inf,dp[i][j][k][turn]+y[i]+x[nxt]);
        newk=k;
        if (newcost<=t[nxt])newk++;
        dp[i][nxt][newk][0]=min(dp[i][nxt][newk][0],newcost);
    }
    else {
        //on j
        //go i
        int nxt=run(i);
        int newcost=min(inf,dp[i][j][k][turn]+x[j]+y[nxt]);
        int newk=k;
        if (newcost<=t[nxt])newk++;
        dp[nxt][j][newk][1]=min(dp[nxt][j][newk][1],newcost);
        //go j
        nxt=nur(j);
        newk=k;
        newcost=min(inf,dp[i][j][k][turn]+x[nxt]-x[j]);
        if (newcost<=t[nxt])newk++;
        dp[i][nxt][newk][0]=min(dp[i][nxt][newk][0],newcost);
    }
    }
    }
    }
    }
    int ans=0;
    for1(i,0,n){
    for1(j,0,n){
    for1(k,1,n){
    for1(l1,0,1){
    if (dp[i][j][k][l1]>=inf)continue;
    ans=max(ans,k);
    //if (i==0)cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k][l1]<<'\n';
    }
    }
    }
    }
    cout<<ans;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 464 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Incorrect 1 ms 596 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 464 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Incorrect 1 ms 596 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 464 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Incorrect 1 ms 596 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 464 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Incorrect 1 ms 596 KB Output isn't correct
17 Halted 0 ms 0 KB -