Submission #226463

# Submission time Handle Problem Language Result Execution time Memory
226463 2020-04-23T21:38:04 Z thebes Collecting Stamps 3 (JOI20_ho_t3) C++14
0 / 100
74 ms 129400 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int MN = 202;
int N, L, i, arr[MN], t[MN]; ll nxt, d, td, k, dis[2][MN][MN][MN];
struct idk{int l, r, k, p; ll t;};
struct pq{bool operator()(const idk&i,const idk&j){return i.t>j.t;}};
priority_queue<idk,vector<idk>,pq> q;

int main(){
    for(scanf("%d%d",&N,&L),i=1;i<=N;i++)
        scanf("%d",&arr[i]);
    for(i=1;i<=N;i++)
        scanf("%d",&t[i]);
    arr[0]=0; t[0]=-1;
    q.push({0,0,0,0,0});
    memset(dis,-1,sizeof(dis));
    while(q.size()){
        idk cur=q.top(); q.pop();
        if(dis[cur.p][cur.l][cur.r][cur.k]!=-1) continue;
        dis[cur.p][cur.l][cur.r][cur.k]=cur.t;
        if((cur.r+1)%N==cur.l%N){
            continue; // cannot expand further
        }
        nxt=cur.r+1;
        if(nxt>N) nxt=0;
        d=arr[nxt]-arr[cur.r];
        if(d<0) d+=L;
        if(!cur.p) td=arr[cur.r]-arr[cur.l];
        else td=0;
        if(td<0) td+=L;
        d+=td;
        if(cur.t+d<=t[nxt]) k=cur.k+1;
        else k=cur.k;
        if(dis[1][cur.l][nxt][k]==-1)
            q.push({cur.l,nxt,k,1,cur.t+d});
        nxt=cur.l-1;
        if(nxt<0) nxt=N;
        d=arr[cur.l]-arr[nxt];
        if(d<0) d+=L;
        if(cur.p) td=arr[cur.r]-arr[cur.l];
        else td=0;
        if(td<0) td+=L;
        d+=td;
        if(cur.t+d<=t[nxt]) k=cur.k+1;
        else k=cur.k;
        if(dis[0][nxt][cur.l][k]==-1)
            q.push({nxt,cur.r,k,0,cur.t+d});
    }
    int ans=0;
    for(i=0;i<=N;i++){
        for(int j=0;j<=N;j++){
            for(int k=0;k<=N;k++){
                if(dis[0][i][j][k]!=-1||dis[1][i][j][k]!=-1)
                    ans=max(ans,k);
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Compilation message

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:39:43: warning: narrowing conversion of 'nxt' from 'll {aka long long int}' to 'int' inside { } [-Wnarrowing]
             q.push({cur.l,nxt,k,1,cur.t+d});
                                           ^
ho_t3.cpp:39:43: warning: narrowing conversion of 'k' from 'll {aka long long int}' to 'int' inside { } [-Wnarrowing]
ho_t3.cpp:51:43: warning: narrowing conversion of 'nxt' from 'll {aka long long int}' to 'int' inside { } [-Wnarrowing]
             q.push({nxt,cur.r,k,0,cur.t+d});
                                           ^
ho_t3.cpp:51:43: warning: narrowing conversion of 'k' from 'll {aka long long int}' to 'int' inside { } [-Wnarrowing]
ho_t3.cpp:14:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(scanf("%d%d",&N,&L),i=1;i<=N;i++)
         ~~~~~~~~~~~~~~~~~~~^~~~
ho_t3.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&arr[i]);
         ~~~~~^~~~~~~~~~~~~~
ho_t3.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&t[i]);
         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 66 ms 129400 KB Output is correct
2 Correct 74 ms 129400 KB Output is correct
3 Incorrect 72 ms 129400 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 66 ms 129400 KB Output is correct
2 Correct 74 ms 129400 KB Output is correct
3 Incorrect 72 ms 129400 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 66 ms 129400 KB Output is correct
2 Correct 74 ms 129400 KB Output is correct
3 Incorrect 72 ms 129400 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 66 ms 129400 KB Output is correct
2 Correct 74 ms 129400 KB Output is correct
3 Incorrect 72 ms 129400 KB Output isn't correct
4 Halted 0 ms 0 KB -