# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
27010 | 2017-07-08T11:22:54 Z | noobprogrammer | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 1000 ms | 236784 KB |
#include <bits/stdc++.h> using namespace std ; int n , m , pr[100010] , 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 ; for(int i=0;i<n;i++) { scanf("%d" , pr+i) ; for( j=0 ; j <= 1e7 ; j+=pr[i]) dp[j] = max(dp[j] , pr[i]) ; } upd(dp[0]-1 , 1) ; cnt[1]++ ; int val = 1 , v , dd , tmp ; for(int 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(int i=0;i<m;i++){ scanf("%d" , &val) ; if(dp[val] == 1e7+1) printf("oo\n") ; else printf("%d\n" , dp[val] ) ; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 103 ms | 236784 KB | Output is correct |
2 | Correct | 173 ms | 236784 KB | Output is correct |
3 | Correct | 109 ms | 236784 KB | Output is correct |
4 | Correct | 76 ms | 236784 KB | Output is correct |
5 | Correct | 153 ms | 236784 KB | Output is correct |
6 | Correct | 106 ms | 236784 KB | Output is correct |
7 | Correct | 116 ms | 236784 KB | Output is correct |
8 | Correct | 123 ms | 236784 KB | Output is correct |
9 | Correct | 226 ms | 236784 KB | Output is correct |
10 | Correct | 266 ms | 236784 KB | Output is correct |
11 | Correct | 219 ms | 236784 KB | Output is correct |
12 | Correct | 79 ms | 236784 KB | Output is correct |
13 | Correct | 493 ms | 236784 KB | Output is correct |
14 | Correct | 463 ms | 236784 KB | Output is correct |
15 | Correct | 186 ms | 236784 KB | Output is correct |
16 | Correct | 149 ms | 236784 KB | Output is correct |
17 | Correct | 146 ms | 236784 KB | Output is correct |
18 | Correct | 99 ms | 236784 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 159 ms | 236784 KB | Output is correct |
2 | Correct | 309 ms | 236784 KB | Output is correct |
3 | Correct | 936 ms | 236784 KB | Output is correct |
4 | Correct | 179 ms | 236784 KB | Output is correct |
5 | Correct | 489 ms | 236784 KB | Output is correct |
6 | Correct | 189 ms | 236784 KB | Output is correct |
7 | Correct | 283 ms | 236784 KB | Output is correct |
8 | Correct | 199 ms | 236784 KB | Output is correct |
9 | Correct | 849 ms | 236784 KB | Output is correct |
10 | Execution timed out | 1000 ms | 236784 KB | Execution timed out |
11 | Correct | 926 ms | 236784 KB | Output is correct |
12 | Correct | 323 ms | 236784 KB | Output is correct |
13 | Correct | 169 ms | 236784 KB | Output is correct |
14 | Correct | 186 ms | 236784 KB | Output is correct |
15 | Correct | 763 ms | 236784 KB | Output is correct |
16 | Correct | 273 ms | 236784 KB | Output is correct |
17 | Correct | 403 ms | 236784 KB | Output is correct |
18 | Correct | 909 ms | 236784 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 863 ms | 236784 KB | Output is correct |
2 | Correct | 829 ms | 236784 KB | Output is correct |
3 | Correct | 703 ms | 236784 KB | Output is correct |
4 | Correct | 376 ms | 236784 KB | Output is correct |
5 | Correct | 433 ms | 236784 KB | Output is correct |
6 | Correct | 576 ms | 236784 KB | Output is correct |
7 | Correct | 839 ms | 236784 KB | Output is correct |
8 | Correct | 906 ms | 236784 KB | Output is correct |
9 | Correct | 833 ms | 236784 KB | Output is correct |
10 | Correct | 359 ms | 236784 KB | Output is correct |
11 | Correct | 363 ms | 236784 KB | Output is correct |
12 | Correct | 389 ms | 236784 KB | Output is correct |
13 | Correct | 826 ms | 236784 KB | Output is correct |
14 | Correct | 299 ms | 236784 KB | Output is correct |
15 | Correct | 473 ms | 236784 KB | Output is correct |
16 | Correct | 539 ms | 236784 KB | Output is correct |
17 | Correct | 839 ms | 236784 KB | Output is correct |
18 | Correct | 736 ms | 236784 KB | Output is correct |
19 | Correct | 279 ms | 236784 KB | Output is correct |
20 | Correct | 989 ms | 236784 KB | Output is correct |
21 | Correct | 353 ms | 236784 KB | Output is correct |
22 | Correct | 919 ms | 236784 KB | Output is correct |
23 | Correct | 483 ms | 236784 KB | Output is correct |
24 | Correct | 186 ms | 236784 KB | Output is correct |
25 | Correct | 409 ms | 236784 KB | Output is correct |
26 | Correct | 419 ms | 236784 KB | Output is correct |
27 | Correct | 803 ms | 236784 KB | Output is correct |
28 | Correct | 159 ms | 236784 KB | Output is correct |
29 | Correct | 969 ms | 236784 KB | Output is correct |
30 | Correct | 939 ms | 236784 KB | Output is correct |
31 | Correct | 329 ms | 236784 KB | Output is correct |
32 | Correct | 283 ms | 236784 KB | Output is correct |
33 | Correct | 163 ms | 236784 KB | Output is correct |
34 | Correct | 839 ms | 236784 KB | Output is correct |
35 | Correct | 223 ms | 236784 KB | Output is correct |
36 | Correct | 746 ms | 236784 KB | Output is correct |
37 | Correct | 426 ms | 236784 KB | Output is correct |
38 | Correct | 499 ms | 236784 KB | Output is correct |
39 | Correct | 199 ms | 236784 KB | Output is correct |
40 | Correct | 533 ms | 236784 KB | Output is correct |
41 | Correct | 576 ms | 236784 KB | Output is correct |
42 | Correct | 486 ms | 236784 KB | Output is correct |