답안 #27015

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
27015 2017-07-08T12:55:07 Z noobprogrammer Brunhilda’s Birthday (BOI13_brunhilda) C++14
93.1746 / 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 ; 
	const 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

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:29:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d" , &pr ) ;
                      ^
brunhilda.cpp:52:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d" , &val) ;
                      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 236396 KB Output is correct
2 Correct 156 ms 236396 KB Output is correct
3 Correct 106 ms 236396 KB Output is correct
4 Correct 103 ms 236396 KB Output is correct
5 Correct 146 ms 236396 KB Output is correct
6 Correct 99 ms 236396 KB Output is correct
7 Correct 113 ms 236396 KB Output is correct
8 Correct 119 ms 236396 KB Output is correct
9 Correct 223 ms 236396 KB Output is correct
10 Correct 256 ms 236396 KB Output is correct
11 Correct 209 ms 236396 KB Output is correct
12 Correct 79 ms 236396 KB Output is correct
13 Correct 409 ms 236396 KB Output is correct
14 Correct 429 ms 236396 KB Output is correct
15 Correct 196 ms 236396 KB Output is correct
16 Correct 149 ms 236396 KB Output is correct
17 Correct 143 ms 236396 KB Output is correct
18 Correct 83 ms 236396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 279 ms 236396 KB Output is correct
2 Correct 356 ms 236396 KB Output is correct
3 Correct 949 ms 236396 KB Output is correct
4 Correct 186 ms 236396 KB Output is correct
5 Correct 669 ms 236396 KB Output is correct
6 Correct 183 ms 236396 KB Output is correct
7 Correct 293 ms 236396 KB Output is correct
8 Correct 183 ms 236396 KB Output is correct
9 Correct 816 ms 236396 KB Output is correct
10 Execution timed out 1000 ms 236396 KB Execution timed out
11 Correct 959 ms 236396 KB Output is correct
12 Correct 329 ms 236396 KB Output is correct
13 Correct 209 ms 236396 KB Output is correct
14 Correct 273 ms 236396 KB Output is correct
15 Correct 823 ms 236396 KB Output is correct
16 Correct 376 ms 236396 KB Output is correct
17 Correct 426 ms 236396 KB Output is correct
18 Correct 893 ms 236396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 869 ms 236396 KB Output is correct
2 Correct 739 ms 236396 KB Output is correct
3 Execution timed out 1000 ms 236396 KB Execution timed out
4 Correct 399 ms 236396 KB Output is correct
5 Correct 439 ms 236396 KB Output is correct
6 Correct 539 ms 236396 KB Output is correct
7 Correct 763 ms 236396 KB Output is correct
8 Correct 863 ms 236396 KB Output is correct
9 Correct 803 ms 236396 KB Output is correct
10 Correct 379 ms 236396 KB Output is correct
11 Correct 359 ms 236396 KB Output is correct
12 Correct 506 ms 236396 KB Output is correct
13 Correct 959 ms 236396 KB Output is correct
14 Correct 326 ms 236396 KB Output is correct
15 Correct 453 ms 236396 KB Output is correct
16 Correct 476 ms 236396 KB Output is correct
17 Correct 689 ms 236396 KB Output is correct
18 Correct 983 ms 236396 KB Output is correct
19 Correct 233 ms 236396 KB Output is correct
20 Execution timed out 1000 ms 236396 KB Execution timed out
21 Correct 376 ms 236396 KB Output is correct
22 Correct 816 ms 236396 KB Output is correct
23 Correct 306 ms 236396 KB Output is correct
24 Correct 199 ms 236396 KB Output is correct
25 Correct 406 ms 236396 KB Output is correct
26 Correct 389 ms 236396 KB Output is correct
27 Execution timed out 1000 ms 236396 KB Execution timed out
28 Correct 149 ms 236396 KB Output is correct
29 Correct 619 ms 236396 KB Output is correct
30 Correct 636 ms 236396 KB Output is correct
31 Correct 299 ms 236396 KB Output is correct
32 Correct 279 ms 236396 KB Output is correct
33 Correct 156 ms 236396 KB Output is correct
34 Correct 789 ms 236396 KB Output is correct
35 Correct 226 ms 236396 KB Output is correct
36 Execution timed out 1000 ms 236396 KB Execution timed out
37 Correct 479 ms 236396 KB Output is correct
38 Correct 539 ms 236396 KB Output is correct
39 Correct 216 ms 236396 KB Output is correct
40 Correct 523 ms 236396 KB Output is correct
41 Correct 686 ms 236396 KB Output is correct
42 Correct 479 ms 236396 KB Output is correct