Submission #27012

# Submission time Handle Problem Language Result Execution time Memory
27012 2017-07-08T11:26:20 Z noobprogrammer Brunhilda’s Birthday (BOI13_brunhilda) C++14
98.5714 / 100
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 ; 
	for( i=0 ; i<n ; i++) {
		scanf("%d" , &pr ) ;
		for( j=0 ; j <= 1e7 ; 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

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:25: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:28:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d" , &pr ) ;
                      ^
brunhilda.cpp:51: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 99 ms 236396 KB Output is correct
2 Correct 163 ms 236396 KB Output is correct
3 Correct 106 ms 236396 KB Output is correct
4 Correct 76 ms 236396 KB Output is correct
5 Correct 146 ms 236396 KB Output is correct
6 Correct 93 ms 236396 KB Output is correct
7 Correct 116 ms 236396 KB Output is correct
8 Correct 119 ms 236396 KB Output is correct
9 Correct 226 ms 236396 KB Output is correct
10 Correct 266 ms 236396 KB Output is correct
11 Correct 229 ms 236396 KB Output is correct
12 Correct 79 ms 236396 KB Output is correct
13 Correct 456 ms 236396 KB Output is correct
14 Correct 446 ms 236396 KB Output is correct
15 Correct 189 ms 236396 KB Output is correct
16 Correct 163 ms 236396 KB Output is correct
17 Correct 129 ms 236396 KB Output is correct
18 Correct 79 ms 236396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 279 ms 236396 KB Output is correct
2 Correct 349 ms 236396 KB Output is correct
3 Correct 883 ms 236396 KB Output is correct
4 Correct 209 ms 236396 KB Output is correct
5 Correct 723 ms 236396 KB Output is correct
6 Correct 169 ms 236396 KB Output is correct
7 Correct 223 ms 236396 KB Output is correct
8 Correct 189 ms 236396 KB Output is correct
9 Correct 739 ms 236396 KB Output is correct
10 Correct 729 ms 236396 KB Output is correct
11 Correct 746 ms 236396 KB Output is correct
12 Correct 306 ms 236396 KB Output is correct
13 Correct 203 ms 236396 KB Output is correct
14 Correct 249 ms 236396 KB Output is correct
15 Correct 786 ms 236396 KB Output is correct
16 Correct 306 ms 236396 KB Output is correct
17 Correct 446 ms 236396 KB Output is correct
18 Correct 856 ms 236396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 796 ms 236396 KB Output is correct
2 Correct 816 ms 236396 KB Output is correct
3 Correct 899 ms 236396 KB Output is correct
4 Correct 329 ms 236396 KB Output is correct
5 Correct 453 ms 236396 KB Output is correct
6 Correct 516 ms 236396 KB Output is correct
7 Correct 686 ms 236396 KB Output is correct
8 Correct 809 ms 236396 KB Output is correct
9 Correct 856 ms 236396 KB Output is correct
10 Correct 379 ms 236396 KB Output is correct
11 Correct 329 ms 236396 KB Output is correct
12 Correct 399 ms 236396 KB Output is correct
13 Correct 876 ms 236396 KB Output is correct
14 Correct 296 ms 236396 KB Output is correct
15 Correct 483 ms 236396 KB Output is correct
16 Correct 543 ms 236396 KB Output is correct
17 Correct 613 ms 236396 KB Output is correct
18 Correct 829 ms 236396 KB Output is correct
19 Correct 276 ms 236396 KB Output is correct
20 Correct 943 ms 236396 KB Output is correct
21 Correct 336 ms 236396 KB Output is correct
22 Correct 956 ms 236396 KB Output is correct
23 Correct 446 ms 236396 KB Output is correct
24 Correct 169 ms 236396 KB Output is correct
25 Correct 426 ms 236396 KB Output is correct
26 Correct 383 ms 236396 KB Output is correct
27 Execution timed out 1000 ms 236396 KB Execution timed out
28 Correct 183 ms 236396 KB Output is correct
29 Correct 689 ms 236396 KB Output is correct
30 Correct 996 ms 236396 KB Output is correct
31 Correct 329 ms 236396 KB Output is correct
32 Correct 309 ms 236396 KB Output is correct
33 Correct 173 ms 236396 KB Output is correct
34 Correct 799 ms 236396 KB Output is correct
35 Correct 196 ms 236396 KB Output is correct
36 Correct 713 ms 236396 KB Output is correct
37 Correct 459 ms 236396 KB Output is correct
38 Correct 586 ms 236396 KB Output is correct
39 Correct 183 ms 236396 KB Output is correct
40 Correct 569 ms 236396 KB Output is correct
41 Correct 739 ms 236396 KB Output is correct
42 Correct 459 ms 236396 KB Output is correct