Submission #490570

#TimeUsernameProblemLanguageResultExecution timeMemory
490570DeadlyCriticBali Sculptures (APIO15_sculpture)C++17
71 / 100
36 ms460 KiB
#include <bits/stdc++.h> // #pragma GCC optimize ("O2,unroll-loops") // #pragma GCC optimize("no-stack-protector,fast-math") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define IOS ios::sync_with_stdio(0), cin.tie(), cout.tie(); #define fr first #define sc second #define all(v) v.begin(), v.end() #define uni(v) sort(all(v)), v.erase(unique(all(v)), v.end()) // #define c0 (v << 1) // #define c1 (c0 | 1) // #define md ((l+r)>>1) using namespace std; typedef long long ll; const int maxN = 1e2+7; ll pef[maxN]; int y[maxN]; bool dp[maxN][maxN]; inline ll range(int l, int r){ return pef[r+1]-pef[l]; } signed main(){IOS int n; int a, b; cin >> n >> a >> b; for(int i = 0; i < n; i++){ cin >> y[i]; } assert(n < maxN); ll ans = 0; ll bads = 0; pef[0] = 0; for(int i = 0; i < n; i++)pef[i+1] = pef[i]+y[i]; ll maxAns = 1ll << 40; for(int bit = 40; bit >= 0; bit--){ bads += (1ll << bit); for(int i = 0; i <= n; i++)for(int j = 0; j <= n; j++)dp[i][j] = 0; for(int i = a; i <= b; i++)dp[0][i] = 1; for(int i = 0; i < n; i++){ for(int k = 0; k < b; k++){ for(int j = 0; j <= i; j++){ if(range(j, i) < maxAns && (range(j, i) & bads) == 0){ dp[i+1][k] |= dp[j][k+1]; } } } } if(dp[n][0] == 0){ bads ^= (1ll << bit); ans ^= (1ll << bit); } } cout << ans << '\n'; }
#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...