Submission #127886

#TimeUsernameProblemLanguageResultExecution timeMemory
127886zoooma13Bali Sculptures (APIO15_sculpture)C++14
0 / 100
2 ms380 KiB
#include <bits/stdc++.h> using namespace std; #define MAX_N 102 int n ,a ,b; int y[MAX_N] ,sum[MAX_N]; int main() { scanf("%d%d%d",&n,&a,&b); assert(n < MAX_N); for(int i=1; i<=n; i++) scanf("%d",&y[i]) ,sum[i] = sum[i-1]+y[i]; vector <int> dp(n+1) ,curr_dp(n+1); int ans = (a == 1 ? sum[n] : 2e9); for(int i=1; i<=n; i++) curr_dp[i] = curr_dp[i-1]+y[i]; for(int k=2; k<=b; k++){ swap(dp ,curr_dp); for(int i=k; i<=n; i++){ curr_dp[i] = 2e9; for(int j=k; j<=i; j++) curr_dp[i] = min(curr_dp[i] ,(sum[i]-sum[j-1])|dp[j-1]); } if(a <= k) ans = min(ans ,curr_dp[n]); } printf("%d\n",ans); } /** 6 1 3 8 1 2 1 5 4 */

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&a,&b); assert(n < MAX_N);
     ~~~~~^~~~~~~~~~~~~~~~~~~
sculpture.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&y[i]) ,sum[i] = sum[i-1]+y[i];
         ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...