Submission #163373

#TimeUsernameProblemLanguageResultExecution timeMemory
163373combi1k1Bali Sculptures (APIO15_sculpture)C++14
0 / 100
4 ms632 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const int N = 2e3 + 1; ll a[N]; ll f[N][N]; int g[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; int A; cin >> A; int B; cin >> B; for(int i = 1 ; i <= n ; ++i) { cin >> a[i]; a[i] += a[i - 1]; } assert(A > 1); if (A > 1) { for(int i = 1 ; i <= n ; ++i) f[i][0] = 1e18; for(int i = 1 ; i <= n ; ++i) for(int j = 1 ; j <= i ; ++j) { f[i][j] = 1e18; for(int k = j - 1 ; k < i ; ++k) f[i][j] = min(f[i][j],f[k][j - 1] | (a[i] - a[k])); } ll ans = 1e18; for(int i = A ; i <= B ; ++i) ans = min(ans,f[n][i]); cout << ans; } else { ll cur_mask = 0; for(int b = 40 ; b >= 0 ; --b) { for(int i = 1 ; i <= n ; ++i) { g[i] = 1e9; int t = 0; for(int j = 0 ; j < i ; ++j) { ll S = a[i] - a[j]; S >>= b; S <<= b; if ((S & cur_mask) != S) continue; g[i] = min(g[i],g[j] + 1); } } if (g[n] > B) cur_mask |= (1ll << b); } cout << cur_mask << endl; } }

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:50:21: warning: unused variable 't' [-Wunused-variable]
                 int t = 0;
                     ^
#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...