Submission #563436

#TimeUsernameProblemLanguageResultExecution timeMemory
563436penguin133Bali Sculptures (APIO15_sculpture)C++14
0 / 100
1 ms372 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int A[200005] ,P[200005]; int n,a,b; int dp[105][105][105]; int calc(int i, int k, int prev){ if(i == n + 1 && !k)return P[i-1] - P[prev]; else if(i == n + 1)return 1e18; else if(dp[i][k][prev])return dp[i][k][prev]; else if(k)return dp[i][k][prev] = min((calc(i+1, k-1, i) | (P[i] - P[prev])), calc(i+1, k, prev)); else return dp[i][k][prev] = calc(i+1, k, prev); } main(){ ios::sync_with_stdio(0);cin.tie(0); cin >> n >> a >> b; for(int i=1;i<=n;i++)cin >> A[i], P[i] = P[i-1] + A[i]; int ans = 1e18; for(int i=a;i<=b;i++)ans = min(ans, calc(1, i, 0)); cout << ans; }

Compilation message (stderr)

sculpture.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   14 | main(){
      | ^~~~
#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...