Submission #152580

# Submission time Handle Problem Language Result Execution time Memory
152580 2019-09-08T13:35:25 Z beso123 Bali Sculptures (APIO15_sculpture) C++14
0 / 100
2 ms 380 KB
#include <bits/stdc++.h>
#define int  long long
using namespace std;
int n,A,B,a[2002],dp[2002][2002],pref[2002];
vector <int> v;
main(){
cin>>n>>A>>B;
for(int k=1;k<=n;k++){
   cin>>a[k];
   pref[k]=pref[k-1]+a[k];
   v.push_back(pref[k]);
}

int ans=pref[n];
for(int k=1;k<=n;k++)
    dp[1][k]=pref[k];
    for(int k=2;k<=B;k++){
       for(int i=k;i<=n;i++){
            int h=pref[i]/k;
        vector <int>::iterator it=lower_bound(v.begin(),v.end(),pref[i]-h);
            int p=distance(v.begin(),it);
            while(v[p]==pref[i]-h)
                p++;
            p++;

            int h1=dp[k-1][p-1] | (pref[i]-pref[p-1]);
            dp[k][i]=h1;
       }
       ans=min(ans,dp[k][n]);
    }
  /*  for(int k=1;k<=B;k++){
        for(int i=1;i<=n;i++){
            cout<<dp[k][i]<<' ';
        }
        cout<<endl;
    }*/
    cout<<ans;
return 0;
}

Compilation message

sculpture.cpp:6:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:15:1: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
 for(int k=1;k<=n;k++)
 ^~~
sculpture.cpp:17:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for(int k=2;k<=B;k++){
     ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 380 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -