Submission #226464

# Submission time Handle Problem Language Result Execution time Memory
226464 2020-04-23T21:42:53 Z thebes Collecting Stamps 3 (JOI20_ho_t3) C++14
25 / 100
2000 ms 178880 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+1)==cur.l%(N+1)){
            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 64 ms 129400 KB Output is correct
2 Correct 63 ms 129400 KB Output is correct
3 Correct 64 ms 129400 KB Output is correct
4 Correct 65 ms 129400 KB Output is correct
5 Correct 64 ms 129400 KB Output is correct
6 Correct 63 ms 129404 KB Output is correct
7 Correct 62 ms 129400 KB Output is correct
8 Correct 63 ms 129400 KB Output is correct
9 Correct 64 ms 129400 KB Output is correct
10 Correct 66 ms 129400 KB Output is correct
11 Correct 63 ms 129400 KB Output is correct
12 Correct 64 ms 129400 KB Output is correct
13 Correct 66 ms 129532 KB Output is correct
14 Correct 71 ms 129400 KB Output is correct
15 Correct 71 ms 129400 KB Output is correct
16 Correct 65 ms 129400 KB Output is correct
17 Correct 63 ms 129400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 129400 KB Output is correct
2 Correct 63 ms 129400 KB Output is correct
3 Correct 64 ms 129400 KB Output is correct
4 Correct 65 ms 129400 KB Output is correct
5 Correct 64 ms 129400 KB Output is correct
6 Correct 63 ms 129404 KB Output is correct
7 Correct 62 ms 129400 KB Output is correct
8 Correct 63 ms 129400 KB Output is correct
9 Correct 64 ms 129400 KB Output is correct
10 Correct 66 ms 129400 KB Output is correct
11 Correct 63 ms 129400 KB Output is correct
12 Correct 64 ms 129400 KB Output is correct
13 Correct 66 ms 129532 KB Output is correct
14 Correct 71 ms 129400 KB Output is correct
15 Correct 71 ms 129400 KB Output is correct
16 Correct 65 ms 129400 KB Output is correct
17 Correct 63 ms 129400 KB Output is correct
18 Correct 66 ms 129528 KB Output is correct
19 Correct 64 ms 129400 KB Output is correct
20 Correct 73 ms 129400 KB Output is correct
21 Correct 74 ms 129400 KB Output is correct
22 Correct 64 ms 129400 KB Output is correct
23 Correct 63 ms 129400 KB Output is correct
24 Correct 66 ms 129400 KB Output is correct
25 Correct 64 ms 129400 KB Output is correct
26 Correct 72 ms 129400 KB Output is correct
27 Correct 66 ms 129400 KB Output is correct
28 Correct 68 ms 129400 KB Output is correct
29 Correct 65 ms 129400 KB Output is correct
30 Correct 64 ms 129400 KB Output is correct
31 Correct 63 ms 129400 KB Output is correct
32 Correct 65 ms 129400 KB Output is correct
33 Correct 67 ms 129400 KB Output is correct
34 Correct 63 ms 129400 KB Output is correct
35 Correct 64 ms 129400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 129400 KB Output is correct
2 Correct 63 ms 129400 KB Output is correct
3 Correct 64 ms 129400 KB Output is correct
4 Correct 65 ms 129400 KB Output is correct
5 Correct 64 ms 129400 KB Output is correct
6 Correct 63 ms 129404 KB Output is correct
7 Correct 62 ms 129400 KB Output is correct
8 Correct 63 ms 129400 KB Output is correct
9 Correct 64 ms 129400 KB Output is correct
10 Correct 66 ms 129400 KB Output is correct
11 Correct 63 ms 129400 KB Output is correct
12 Correct 64 ms 129400 KB Output is correct
13 Correct 66 ms 129532 KB Output is correct
14 Correct 71 ms 129400 KB Output is correct
15 Correct 71 ms 129400 KB Output is correct
16 Correct 65 ms 129400 KB Output is correct
17 Correct 63 ms 129400 KB Output is correct
18 Correct 882 ms 154188 KB Output is correct
19 Correct 508 ms 141784 KB Output is correct
20 Correct 161 ms 132584 KB Output is correct
21 Correct 342 ms 141912 KB Output is correct
22 Correct 600 ms 141784 KB Output is correct
23 Correct 173 ms 132588 KB Output is correct
24 Correct 101 ms 132624 KB Output is correct
25 Correct 167 ms 132584 KB Output is correct
26 Correct 86 ms 130292 KB Output is correct
27 Correct 195 ms 132588 KB Output is correct
28 Correct 90 ms 131056 KB Output is correct
29 Correct 175 ms 132584 KB Output is correct
30 Correct 103 ms 132588 KB Output is correct
31 Correct 152 ms 132584 KB Output is correct
32 Correct 93 ms 131056 KB Output is correct
33 Correct 142 ms 132588 KB Output is correct
34 Correct 75 ms 130292 KB Output is correct
35 Correct 88 ms 130292 KB Output is correct
36 Correct 77 ms 130292 KB Output is correct
37 Correct 94 ms 130292 KB Output is correct
38 Correct 92 ms 131184 KB Output is correct
39 Correct 94 ms 130292 KB Output is correct
40 Correct 85 ms 131184 KB Output is correct
41 Correct 1502 ms 178880 KB Output is correct
42 Correct 80 ms 129976 KB Output is correct
43 Correct 1517 ms 178780 KB Output is correct
44 Correct 81 ms 129848 KB Output is correct
45 Correct 1522 ms 178748 KB Output is correct
46 Correct 94 ms 129848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 129400 KB Output is correct
2 Correct 63 ms 129400 KB Output is correct
3 Correct 64 ms 129400 KB Output is correct
4 Correct 65 ms 129400 KB Output is correct
5 Correct 64 ms 129400 KB Output is correct
6 Correct 63 ms 129404 KB Output is correct
7 Correct 62 ms 129400 KB Output is correct
8 Correct 63 ms 129400 KB Output is correct
9 Correct 64 ms 129400 KB Output is correct
10 Correct 66 ms 129400 KB Output is correct
11 Correct 63 ms 129400 KB Output is correct
12 Correct 64 ms 129400 KB Output is correct
13 Correct 66 ms 129532 KB Output is correct
14 Correct 71 ms 129400 KB Output is correct
15 Correct 71 ms 129400 KB Output is correct
16 Correct 65 ms 129400 KB Output is correct
17 Correct 63 ms 129400 KB Output is correct
18 Correct 66 ms 129528 KB Output is correct
19 Correct 64 ms 129400 KB Output is correct
20 Correct 73 ms 129400 KB Output is correct
21 Correct 74 ms 129400 KB Output is correct
22 Correct 64 ms 129400 KB Output is correct
23 Correct 63 ms 129400 KB Output is correct
24 Correct 66 ms 129400 KB Output is correct
25 Correct 64 ms 129400 KB Output is correct
26 Correct 72 ms 129400 KB Output is correct
27 Correct 66 ms 129400 KB Output is correct
28 Correct 68 ms 129400 KB Output is correct
29 Correct 65 ms 129400 KB Output is correct
30 Correct 64 ms 129400 KB Output is correct
31 Correct 63 ms 129400 KB Output is correct
32 Correct 65 ms 129400 KB Output is correct
33 Correct 67 ms 129400 KB Output is correct
34 Correct 63 ms 129400 KB Output is correct
35 Correct 64 ms 129400 KB Output is correct
36 Correct 882 ms 154188 KB Output is correct
37 Correct 508 ms 141784 KB Output is correct
38 Correct 161 ms 132584 KB Output is correct
39 Correct 342 ms 141912 KB Output is correct
40 Correct 600 ms 141784 KB Output is correct
41 Correct 173 ms 132588 KB Output is correct
42 Correct 101 ms 132624 KB Output is correct
43 Correct 167 ms 132584 KB Output is correct
44 Correct 86 ms 130292 KB Output is correct
45 Correct 195 ms 132588 KB Output is correct
46 Correct 90 ms 131056 KB Output is correct
47 Correct 175 ms 132584 KB Output is correct
48 Correct 103 ms 132588 KB Output is correct
49 Correct 152 ms 132584 KB Output is correct
50 Correct 93 ms 131056 KB Output is correct
51 Correct 142 ms 132588 KB Output is correct
52 Correct 75 ms 130292 KB Output is correct
53 Correct 88 ms 130292 KB Output is correct
54 Correct 77 ms 130292 KB Output is correct
55 Correct 94 ms 130292 KB Output is correct
56 Correct 92 ms 131184 KB Output is correct
57 Correct 94 ms 130292 KB Output is correct
58 Correct 85 ms 131184 KB Output is correct
59 Correct 1502 ms 178880 KB Output is correct
60 Correct 80 ms 129976 KB Output is correct
61 Correct 1517 ms 178780 KB Output is correct
62 Correct 81 ms 129848 KB Output is correct
63 Correct 1522 ms 178748 KB Output is correct
64 Correct 94 ms 129848 KB Output is correct
65 Correct 1396 ms 154228 KB Output is correct
66 Correct 1196 ms 154208 KB Output is correct
67 Correct 1074 ms 154248 KB Output is correct
68 Correct 935 ms 154184 KB Output is correct
69 Correct 1447 ms 154168 KB Output is correct
70 Correct 1402 ms 154328 KB Output is correct
71 Correct 1046 ms 154188 KB Output is correct
72 Correct 1517 ms 154220 KB Output is correct
73 Correct 482 ms 141784 KB Output is correct
74 Correct 1094 ms 154200 KB Output is correct
75 Correct 989 ms 154056 KB Output is correct
76 Correct 1578 ms 154184 KB Output is correct
77 Correct 1301 ms 154056 KB Output is correct
78 Correct 907 ms 154196 KB Output is correct
79 Correct 1296 ms 154056 KB Output is correct
80 Correct 1563 ms 154064 KB Output is correct
81 Correct 900 ms 154056 KB Output is correct
82 Correct 553 ms 141912 KB Output is correct
83 Correct 1401 ms 154192 KB Output is correct
84 Correct 575 ms 141784 KB Output is correct
85 Correct 661 ms 154056 KB Output is correct
86 Correct 672 ms 141892 KB Output is correct
87 Correct 1325 ms 154240 KB Output is correct
88 Execution timed out 2108 ms 178704 KB Time limit exceeded
89 Halted 0 ms 0 KB -