답안 #154334

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154334 2019-09-20T19:09:56 Z brcode Brunhilda’s Birthday (BOI13_brunhilda) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>

using namespace std;
const int MAXN = 1e7+5;
int arr[MAXN2];
int dp[MAXN];
int dp2[MAXN];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
    }
    for(int i=0;i<arr[n];i++){
        dp[i] = 1;
    }
    for(int i=arr[n];i<MAXN;i++){
        dp[i] = 1e9;
    }
    for(int i=1;i<=n;i++){
        for(int j=arr[i]-1;j<MAXN;j+=arr[i]){

            dp2[j] = max(dp2[j],arr[i]-1);
            //cout<<j<<" "<<dp2[j]<<endl;
        }
    }
    for(int i=MAXN-1;i>=0;i--){
        dp2[i] = max(dp2[i],dp2[i+1]-1);
    }
    for(int i=arr[n];i<MAXN;i++){
        dp[i] = min(dp[i],dp[i-dp2[i]]+1);
    }
    for(int i=1;i<=m;i++){
        int x;
        cin>>x;
        if(dp[x]==1e9){
            cout<<"oo"<<endl;
        }else{
            cout<<dp[x]<<endl;
        }

    }

}

Compilation message

brunhilda.cpp:5:9: error: 'MAXN2' was not declared in this scope
 int arr[MAXN2];
         ^~~~~
brunhilda.cpp:5:9: note: suggested alternative: 'MAXN'
 int arr[MAXN2];
         ^~~~~
         MAXN
brunhilda.cpp: In function 'int main()':
brunhilda.cpp:12:14: error: 'arr' was not declared in this scope
         cin>>arr[i];
              ^~~
brunhilda.cpp:14:19: error: 'arr' was not declared in this scope
     for(int i=0;i<arr[n];i++){
                   ^~~
brunhilda.cpp:17:15: error: 'arr' was not declared in this scope
     for(int i=arr[n];i<MAXN;i++){
               ^~~
brunhilda.cpp:21:19: error: 'arr' was not declared in this scope
         for(int j=arr[i]-1;j<MAXN;j+=arr[i]){
                   ^~~
brunhilda.cpp:30:15: error: 'arr' was not declared in this scope
     for(int i=arr[n];i<MAXN;i++){
               ^~~