답안 #27013

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
27013 2017-07-08T11:31:07 Z noobprogrammer Brunhilda’s Birthday (BOI13_brunhilda) C++14
96.0317 / 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) ;
                      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 106 ms 236396 KB Output is correct
2 Correct 159 ms 236396 KB Output is correct
3 Correct 116 ms 236396 KB Output is correct
4 Correct 63 ms 236396 KB Output is correct
5 Correct 99 ms 236396 KB Output is correct
6 Correct 89 ms 236396 KB Output is correct
7 Correct 99 ms 236396 KB Output is correct
8 Correct 123 ms 236396 KB Output is correct
9 Correct 196 ms 236396 KB Output is correct
10 Correct 266 ms 236396 KB Output is correct
11 Correct 263 ms 236396 KB Output is correct
12 Correct 63 ms 236396 KB Output is correct
13 Correct 456 ms 236396 KB Output is correct
14 Correct 416 ms 236396 KB Output is correct
15 Correct 216 ms 236396 KB Output is correct
16 Correct 173 ms 236396 KB Output is correct
17 Correct 139 ms 236396 KB Output is correct
18 Correct 76 ms 236396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 263 ms 236396 KB Output is correct
2 Correct 333 ms 236396 KB Output is correct
3 Correct 846 ms 236396 KB Output is correct
4 Correct 209 ms 236396 KB Output is correct
5 Correct 716 ms 236396 KB Output is correct
6 Correct 203 ms 236396 KB Output is correct
7 Correct 276 ms 236396 KB Output is correct
8 Correct 196 ms 236396 KB Output is correct
9 Correct 776 ms 236396 KB Output is correct
10 Execution timed out 1000 ms 236396 KB Execution timed out
11 Correct 893 ms 236396 KB Output is correct
12 Correct 329 ms 236396 KB Output is correct
13 Correct 243 ms 236396 KB Output is correct
14 Correct 253 ms 236396 KB Output is correct
15 Correct 853 ms 236396 KB Output is correct
16 Correct 356 ms 236396 KB Output is correct
17 Correct 476 ms 236396 KB Output is correct
18 Correct 759 ms 236396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 826 ms 236396 KB Output is correct
2 Correct 893 ms 236396 KB Output is correct
3 Correct 933 ms 236396 KB Output is correct
4 Correct 393 ms 236396 KB Output is correct
5 Correct 416 ms 236396 KB Output is correct
6 Correct 496 ms 236396 KB Output is correct
7 Correct 753 ms 236396 KB Output is correct
8 Correct 633 ms 236396 KB Output is correct
9 Correct 503 ms 236396 KB Output is correct
10 Correct 363 ms 236396 KB Output is correct
11 Correct 313 ms 236396 KB Output is correct
12 Correct 423 ms 236396 KB Output is correct
13 Correct 873 ms 236396 KB Output is correct
14 Correct 306 ms 236396 KB Output is correct
15 Correct 419 ms 236396 KB Output is correct
16 Correct 533 ms 236396 KB Output is correct
17 Correct 706 ms 236396 KB Output is correct
18 Correct 913 ms 236396 KB Output is correct
19 Correct 219 ms 236396 KB Output is correct
20 Correct 993 ms 236396 KB Output is correct
21 Correct 353 ms 236396 KB Output is correct
22 Correct 993 ms 236396 KB Output is correct
23 Correct 316 ms 236396 KB Output is correct
24 Correct 183 ms 236396 KB Output is correct
25 Correct 393 ms 236396 KB Output is correct
26 Correct 363 ms 236396 KB Output is correct
27 Execution timed out 1000 ms 236396 KB Execution timed out
28 Correct 186 ms 236396 KB Output is correct
29 Correct 966 ms 236396 KB Output is correct
30 Correct 693 ms 236396 KB Output is correct
31 Correct 306 ms 236396 KB Output is correct
32 Correct 259 ms 236396 KB Output is correct
33 Correct 166 ms 236396 KB Output is correct
34 Correct 773 ms 236396 KB Output is correct
35 Correct 213 ms 236396 KB Output is correct
36 Execution timed out 1000 ms 236396 KB Execution timed out
37 Correct 449 ms 236396 KB Output is correct
38 Correct 599 ms 236396 KB Output is correct
39 Correct 216 ms 236396 KB Output is correct
40 Correct 529 ms 236396 KB Output is correct
41 Correct 619 ms 236396 KB Output is correct
42 Correct 516 ms 236396 KB Output is correct