# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
27014 | 2017-07-08T11:33:41 Z | noobprogrammer | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 1000 ms | 236396 KB |
#include <bits/stdc++.h> using namespace std ; int n , m , pr , cnt[10000010] , ptr , dp[10000010] , nc = 1 ; int fr[10000010] , bk[10000010] , vv[10000010] , nxt[10000010] ; const int N = 1e7 ; void upd(int x,int y){ if(fr[x] == 0) { bk[x] = fr[x] = nc ; vv[nc] = y ; nc++ ; } else { nxt[bk[x]] = nc ; vv[nc] = y ; bk[x] = nc ; nc++; } } int main(){ // freopen("in.txt" , "r" , stdin) ; // freopen("out.txt" , "w" , stdout) ; scanf("%d%d" , &n,&m ) ; int j , i ; int xx = N+1 ; for( i=0 ; i<n ; i++) { scanf("%d" , &pr ) ; for( j=0 ; j < xx ; j+=pr) dp[j] = max(dp[j] , pr) ; } upd(dp[0]-1 , 1) ; cnt[1]++ ; int val = 1 , v , dd , tmp ; for(i=1;i<=N;i++){ while(!cnt[val] && val <= 1e7 ) ++val ; dd = val ; v = fr[i] ; while(v != bk[i]){ --cnt[vv[v]] ; v = nxt[v] ; } cnt[vv[v]]-- ; tmp = dp[i] ; dp[i] = dd; if(dp[i] == 1e7+1) continue ; if(!tmp) continue ; upd(i+tmp-1 , dp[i] + 1 ) ; cnt[dp[i]+1]++ ; } for(i=0;i<m;i++){ scanf("%d" , &val) ; if(dp[val] == 1e7+1) printf("oo\n") ; else printf("%d\n" , dp[val] ) ; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 86 ms | 236396 KB | Output is correct |
2 | Correct | 159 ms | 236396 KB | Output is correct |
3 | Correct | 113 ms | 236396 KB | Output is correct |
4 | Correct | 83 ms | 236396 KB | Output is correct |
5 | Correct | 139 ms | 236396 KB | Output is correct |
6 | Correct | 89 ms | 236396 KB | Output is correct |
7 | Correct | 109 ms | 236396 KB | Output is correct |
8 | Correct | 116 ms | 236396 KB | Output is correct |
9 | Correct | 213 ms | 236396 KB | Output is correct |
10 | Correct | 236 ms | 236396 KB | Output is correct |
11 | Correct | 213 ms | 236396 KB | Output is correct |
12 | Correct | 66 ms | 236396 KB | Output is correct |
13 | Correct | 433 ms | 236396 KB | Output is correct |
14 | Correct | 423 ms | 236396 KB | Output is correct |
15 | Correct | 193 ms | 236396 KB | Output is correct |
16 | Correct | 156 ms | 236396 KB | Output is correct |
17 | Correct | 139 ms | 236396 KB | Output is correct |
18 | Correct | 83 ms | 236396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 279 ms | 236396 KB | Output is correct |
2 | Correct | 316 ms | 236396 KB | Output is correct |
3 | Correct | 959 ms | 236396 KB | Output is correct |
4 | Correct | 226 ms | 236396 KB | Output is correct |
5 | Correct | 696 ms | 236396 KB | Output is correct |
6 | Correct | 186 ms | 236396 KB | Output is correct |
7 | Correct | 259 ms | 236396 KB | Output is correct |
8 | Correct | 196 ms | 236396 KB | Output is correct |
9 | Correct | 689 ms | 236396 KB | Output is correct |
10 | Correct | 863 ms | 236396 KB | Output is correct |
11 | Correct | 496 ms | 236396 KB | Output is correct |
12 | Correct | 249 ms | 236396 KB | Output is correct |
13 | Correct | 213 ms | 236396 KB | Output is correct |
14 | Correct | 209 ms | 236396 KB | Output is correct |
15 | Correct | 453 ms | 236396 KB | Output is correct |
16 | Correct | 343 ms | 236396 KB | Output is correct |
17 | Correct | 469 ms | 236396 KB | Output is correct |
18 | Correct | 873 ms | 236396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 809 ms | 236396 KB | Output is correct |
2 | Execution timed out | 1000 ms | 236396 KB | Execution timed out |
3 | Correct | 849 ms | 236396 KB | Output is correct |
4 | Correct | 376 ms | 236396 KB | Output is correct |
5 | Correct | 459 ms | 236396 KB | Output is correct |
6 | Correct | 493 ms | 236396 KB | Output is correct |
7 | Correct | 716 ms | 236396 KB | Output is correct |
8 | Correct | 903 ms | 236396 KB | Output is correct |
9 | Correct | 586 ms | 236396 KB | Output is correct |
10 | Correct | 389 ms | 236396 KB | Output is correct |
11 | Correct | 359 ms | 236396 KB | Output is correct |
12 | Correct | 453 ms | 236396 KB | Output is correct |
13 | Correct | 723 ms | 236396 KB | Output is correct |
14 | Correct | 303 ms | 236396 KB | Output is correct |
15 | Correct | 526 ms | 236396 KB | Output is correct |
16 | Correct | 519 ms | 236396 KB | Output is correct |
17 | Correct | 773 ms | 236396 KB | Output is correct |
18 | Correct | 933 ms | 236396 KB | Output is correct |
19 | Correct | 296 ms | 236396 KB | Output is correct |
20 | Execution timed out | 1000 ms | 236396 KB | Execution timed out |
21 | Correct | 343 ms | 236396 KB | Output is correct |
22 | Correct | 773 ms | 236396 KB | Output is correct |
23 | Correct | 253 ms | 236396 KB | Output is correct |
24 | Correct | 179 ms | 236396 KB | Output is correct |
25 | Correct | 343 ms | 236396 KB | Output is correct |
26 | Correct | 353 ms | 236396 KB | Output is correct |
27 | Execution timed out | 1000 ms | 236396 KB | Execution timed out |
28 | Correct | 176 ms | 236396 KB | Output is correct |
29 | Correct | 789 ms | 236396 KB | Output is correct |
30 | Correct | 836 ms | 236396 KB | Output is correct |
31 | Correct | 309 ms | 236396 KB | Output is correct |
32 | Correct | 316 ms | 236396 KB | Output is correct |
33 | Correct | 169 ms | 236396 KB | Output is correct |
34 | Correct | 793 ms | 236396 KB | Output is correct |
35 | Correct | 206 ms | 236396 KB | Output is correct |
36 | Correct | 733 ms | 236396 KB | Output is correct |
37 | Correct | 429 ms | 236396 KB | Output is correct |
38 | Correct | 569 ms | 236396 KB | Output is correct |
39 | Correct | 219 ms | 236396 KB | Output is correct |
40 | Correct | 483 ms | 236396 KB | Output is correct |
41 | Correct | 703 ms | 236396 KB | Output is correct |
42 | Correct | 483 ms | 236396 KB | Output is correct |