Submission #27001

# Submission time Handle Problem Language Result Execution time Memory
27001 2017-07-08T10:32:30 Z noobprogrammer Brunhilda’s Birthday (BOI13_brunhilda) C++14
5.55556 / 100
413 ms 262144 KB
#include <bits/stdc++.h>
using namespace std ;

int n , m , pr[100010] , mx[10000010] , cnt[10000010] , ptr , dp[10000010] ;
vector<int> srt[1000010] ;
const int N = 1e6 ; 

int main(){
	// freopen("in.txt" , "r" , stdin) ;
	// freopen("out.txt" , "w" , stdout) ;
	scanf("%d%d" , &n,&m ) ;
	for(int i=0;i<n;i++) {
		scanf("%d" , pr+i) ;
		for(int j=0 ; j <= (int)1e7 ; j+=pr[i]) mx[j] = max(mx[j] , pr[i]) ;
	}
	srt[mx[0] - 1].push_back(1) ; cnt[1]++ ;
	int val = 1 ;
	for(int i=1;i<=N;i++){
		while(!cnt[val] && val <= 1e7 )	val++ ;
		dp[i] = val ;
		for(int v : srt[i]) cnt[v]-- ;
		if(dp[i] == 1e7+1) continue ;
		if(!mx[i]) continue ;
		srt[i+mx[i]-1].push_back(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

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:11:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d" , &n,&m ) ;
                         ^
brunhilda.cpp:13:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d" , pr+i) ;
                      ^
brunhilda.cpp:27:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d" , &val) ;
                      ^
# Verdict Execution time Memory Grader output
1 Correct 59 ms 143036 KB Output is correct
2 Runtime error 96 ms 159536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Correct 76 ms 147260 KB Output is correct
4 Runtime error 33 ms 145280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 79 ms 150428 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Correct 53 ms 143036 KB Output is correct
7 Correct 69 ms 147260 KB Output is correct
8 Correct 119 ms 158348 KB Output is correct
9 Memory limit exceeded 139 ms 262144 KB Memory limit exceeded
10 Runtime error 169 ms 160988 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 133 ms 159008 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 29 ms 144752 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 326 ms 162308 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 279 ms 162308 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 119 ms 159536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 113 ms 159536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 79 ms 150164 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 39 ms 145280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 63 ms 145544 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 73 ms 143036 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 389 ms 156104 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 123 ms 153464 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 199 ms 153200 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 76 ms 157820 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 59 ms 145544 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 113 ms 152936 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 219 ms 154520 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 396 ms 156104 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 343 ms 160724 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 196 ms 159932 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 49 ms 147788 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 149 ms 153464 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 313 ms 154520 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 93 ms 143036 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 289 ms 162836 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 169 ms 143036 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 309 ms 154388 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 396 ms 156368 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 379 ms 156368 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 206 ms 159536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 103 ms 145940 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 346 ms 161384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 286 ms 152804 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 299 ms 154388 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 306 ms 154388 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 283 ms 159668 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 209 ms 157424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 316 ms 161516 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 383 ms 159668 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 183 ms 161252 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 323 ms 162308 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 369 ms 163760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 286 ms 154388 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 406 ms 156368 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 59 ms 148976 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 396 ms 156368 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 176 ms 161516 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 389 ms 155840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 106 ms 146996 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 56 ms 148052 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 263 ms 160328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 193 ms 159536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 413 ms 156896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 83 ms 151880 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 376 ms 155840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 326 ms 155708 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 99 ms 150956 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 166 ms 154916 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 43 ms 145808 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Runtime error 273 ms 152804 KB Execution killed with signal 11 (could be triggered by violating memory limits)
35 Runtime error 83 ms 152144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 353 ms 155444 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Runtime error 126 ms 145940 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Runtime error 333 ms 161384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 93 ms 149372 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 276 ms 159668 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Runtime error 189 ms 143036 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Runtime error 406 ms 163364 KB Execution killed with signal 11 (could be triggered by violating memory limits)