Submission #111013

# Submission time Handle Problem Language Result Execution time Memory
111013 2019-05-13T14:30:33 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=0;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=0;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 2100 invokes undefined behavior [-Waggressive-loop-optimizations]
             dp[i][j]=inf;
             ~~~~~~~~^~~~
sculpture.cpp:9:22: note: within this loop
         for(int j=0;j<=2100;j++){
                     ~^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 3 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 3 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 2 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 2 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Incorrect 3 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -