답안 #111014

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
111014 2019-05-13T14:30:58 Z _demon_ Bali Sculptures (APIO15_sculpture) C++14
0 / 100
3 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
int n,x,y;
int a[109];
int inf=1000000009;
int dp[109][2100];
void memo(){
    for(int i=1;i<=n;i++){
        for(int j=1;j<=2100;j++){
            dp[i][j]=inf;
        }
    }
    dp[0][0]=0;
}
int main(){
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++) cin>>a[i];
    memo();
    for(int i=1;i<=n;i++){
        int sum=0;
        for(int j=i;j>=1;j--){
            sum+=a[j];
            for(int k=0;k<=2050;k++){
                if(dp[j-1][k]==inf) continue;
                dp[i][sum|k]=min(dp[i][sum|k],dp[j-1][k]+1);
            }
        }
    }
    int ans=inf;
    for(int i=1;i<=2050;i++){
        if(dp[n][i]!=inf){
            cout<<i<<endl;
            exit(0);
        }
    }
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:29:9: warning: unused variable 'ans' [-Wunused-variable]
     int ans=inf;
         ^~~
sculpture.cpp: In function 'void memo()':
sculpture.cpp:10:21: warning: iteration 2099 invokes undefined behavior [-Waggressive-loop-optimizations]
             dp[i][j]=inf;
             ~~~~~~~~^~~~
sculpture.cpp:9:22: note: within this loop
         for(int j=1;j<=2100;j++){
                     ~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -