Submission #27011

# Submission time Handle Problem Language Result Execution time Memory
27011 2017-07-08T11:25:50 Z noobprogrammer Brunhilda’s Birthday (BOI13_brunhilda) C++14
Compilation error
0 ms 0 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[i]) 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:29:32: error: invalid types 'int[int]' for array subscript
   for( j=0 ; j <= 1e7 ; j+=pr[i]) dp[j] = max(dp[j] , pr) ;
                                ^
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) ;
                      ^