# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31915 | 2017-09-14T12:33:27 Z | chonka | Brunhilda’s Birthday (BOI13_brunhilda) | C++ | 479 ms | 80928 KB |
#include<iostream> #include<stdio.h> #include<vector> #include<queue> using namespace std ; #define MAXN 100007 int n , m ; int a[ MAXN ] ; int b[ MAXN ] ; int ans[ 100 * MAXN ] ; int lim ; int f[ 100 * MAXN ] ; void input ( ) { scanf ( "%d%d" , &n , &m ) ; int i , j ; lim = 1 ; for ( i = 1 ; i <= 7 ; i ++ ) { lim *= 10 ; } for ( i = 1 ; i <= n ; i ++ ) { scanf ( "%d" , &a[ i ] ) ; for ( j = 0 ; j <= lim ; j += a[ i ] ) { f[ j ] = a[ i ] ; } } } void solve ( ) { int i , j ; long long prod = 1 ; for ( i = n ; i >= 1 ; i -- ) { prod *= a[ i ] ; if ( prod > lim ) { prod = lim + 1 ; } } int lst = 0 ; for ( i = 1 ; i <= lim ; i ++ ) { ans[ i ] = -1 ; } for ( i = 1 ; i < prod ; i ++ ) { while ( f[ lst ] == 0 || lst + f[ lst ] <= i ) { lst ++ ; } if ( lst >= i ) { ans[ i ] = -1 ; } else { ans[ i ] = ans[ lst ] + 1 ; } } while ( m != 0 ) { m -- ; int x ; scanf ( "%d" , &x ) ; if ( ans[ x ] != -1 ) { printf ( "%d\n" , ans[ x ] ) ; } else { printf ( "oo\n" ) ; } } } int main ( ) { input ( ) ; solve ( ) ; return 0 ; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 80928 KB | Output is correct |
2 | Correct | 123 ms | 80928 KB | Output is correct |
3 | Correct | 46 ms | 80928 KB | Output is correct |
4 | Correct | 66 ms | 80928 KB | Output is correct |
5 | Correct | 126 ms | 80928 KB | Output is correct |
6 | Correct | 19 ms | 80928 KB | Output is correct |
7 | Correct | 36 ms | 80928 KB | Output is correct |
8 | Correct | 63 ms | 80928 KB | Output is correct |
9 | Correct | 163 ms | 80928 KB | Output is correct |
10 | Correct | 169 ms | 80928 KB | Output is correct |
11 | Correct | 163 ms | 80928 KB | Output is correct |
12 | Correct | 66 ms | 80928 KB | Output is correct |
13 | Correct | 329 ms | 80928 KB | Output is correct |
14 | Correct | 329 ms | 80928 KB | Output is correct |
15 | Correct | 146 ms | 80928 KB | Output is correct |
16 | Correct | 136 ms | 80928 KB | Output is correct |
17 | Correct | 126 ms | 80928 KB | Output is correct |
18 | Correct | 59 ms | 80928 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 103 ms | 80928 KB | Output is correct |
2 | Correct | 126 ms | 80928 KB | Output is correct |
3 | Correct | 443 ms | 80928 KB | Output is correct |
4 | Correct | 173 ms | 80928 KB | Output is correct |
5 | Correct | 269 ms | 80928 KB | Output is correct |
6 | Correct | 123 ms | 80928 KB | Output is correct |
7 | Correct | 96 ms | 80928 KB | Output is correct |
8 | Correct | 149 ms | 80928 KB | Output is correct |
9 | Correct | 299 ms | 80928 KB | Output is correct |
10 | Correct | 376 ms | 80928 KB | Output is correct |
11 | Correct | 359 ms | 80928 KB | Output is correct |
12 | Correct | 209 ms | 80928 KB | Output is correct |
13 | Correct | 83 ms | 80928 KB | Output is correct |
14 | Correct | 149 ms | 80928 KB | Output is correct |
15 | Correct | 289 ms | 80928 KB | Output is correct |
16 | Correct | 109 ms | 80928 KB | Output is correct |
17 | Correct | 293 ms | 80928 KB | Output is correct |
18 | Correct | 289 ms | 80928 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 306 ms | 80928 KB | Output is correct |
2 | Correct | 403 ms | 80928 KB | Output is correct |
3 | Correct | 419 ms | 80928 KB | Output is correct |
4 | Correct | 229 ms | 80928 KB | Output is correct |
5 | Correct | 199 ms | 80928 KB | Output is correct |
6 | Correct | 396 ms | 80928 KB | Output is correct |
7 | Correct | 336 ms | 80928 KB | Output is correct |
8 | Correct | 353 ms | 80928 KB | Output is correct |
9 | Correct | 336 ms | 80928 KB | Output is correct |
10 | Correct | 293 ms | 80928 KB | Output is correct |
11 | Correct | 243 ms | 80928 KB | Output is correct |
12 | Correct | 323 ms | 80928 KB | Output is correct |
13 | Correct | 423 ms | 80928 KB | Output is correct |
14 | Correct | 209 ms | 80928 KB | Output is correct |
15 | Correct | 326 ms | 80928 KB | Output is correct |
16 | Correct | 343 ms | 80928 KB | Output is correct |
17 | Correct | 313 ms | 80928 KB | Output is correct |
18 | Correct | 396 ms | 80928 KB | Output is correct |
19 | Correct | 143 ms | 80928 KB | Output is correct |
20 | Correct | 446 ms | 80928 KB | Output is correct |
21 | Correct | 249 ms | 80928 KB | Output is correct |
22 | Correct | 449 ms | 80928 KB | Output is correct |
23 | Correct | 206 ms | 80928 KB | Output is correct |
24 | Correct | 153 ms | 80928 KB | Output is correct |
25 | Correct | 303 ms | 80928 KB | Output is correct |
26 | Correct | 249 ms | 80928 KB | Output is correct |
27 | Correct | 479 ms | 80928 KB | Output is correct |
28 | Correct | 149 ms | 80928 KB | Output is correct |
29 | Correct | 453 ms | 80928 KB | Output is correct |
30 | Correct | 419 ms | 80928 KB | Output is correct |
31 | Correct | 206 ms | 80928 KB | Output is correct |
32 | Correct | 239 ms | 80928 KB | Output is correct |
33 | Correct | 113 ms | 80928 KB | Output is correct |
34 | Correct | 333 ms | 80928 KB | Output is correct |
35 | Correct | 173 ms | 80928 KB | Output is correct |
36 | Correct | 466 ms | 80928 KB | Output is correct |
37 | Correct | 199 ms | 80928 KB | Output is correct |
38 | Correct | 393 ms | 80928 KB | Output is correct |
39 | Correct | 179 ms | 80928 KB | Output is correct |
40 | Correct | 266 ms | 80928 KB | Output is correct |
41 | Correct | 223 ms | 80928 KB | Output is correct |
42 | Correct | 336 ms | 80928 KB | Output is correct |