Submission #185639

#TimeUsernameProblemLanguageResultExecution timeMemory
185639dndhkBali Sculptures (APIO15_sculpture)C++14
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAX_N = 100; const int INF = 10000000; int N, A, B; vector<ll> v; ll dp[MAX_N+1][MAX_N+1]; ll ans; ll sum(ll x, ll y){ return dp[1][y] - dp[1][x-1]; } int main(){ scanf("%d%d%d", &N, &A, &B); v.pb(0LL); for(int i=1 ;i<=N; i++){ ll x; scanf("%lld", &x); v.pb(x); } for(int i=1; i<=N; i++){ dp[1][i] = dp[1][i-1] + v[i]; } for(int k=2; k<=N; k++){ for(int i=k; i<=N; i++){ dp[k][i] = (v[i] | dp[k-1][i-1]); for(int j=i-1; j>=k; j--){ dp[k][i] = min(dp[k][i], (sum(j, i) | dp[k-1][j-1])); } //cout<<k<<" "<<i<<" "<<dp[k][i]<<endl; } } ans = dp[A][N]; for(int i=A; i<=B; i++){ ans = min(ans, dp[i][N]); } cout<<ans; return 0; }

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &N, &A, &B);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   ll x; scanf("%lld", &x);
         ~~~~~^~~~~~~~~~~~
#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...