제출 #527588

#제출 시각아이디문제언어결과실행 시간메모리
527588SlavicGBali Sculptures (APIO15_sculpture)C++17
71 / 100
1085 ms16160 KiB
#include "bits/stdc++.h" using namespace std; #define ll long long #define forn(i,n) for(int i=0;i<n;i++) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(),v.rend() #define pb push_back #define sz(a) (int)a.size() const int N = 2005; ll p[N]; ll sum(int l, int r) { return p[r] - (l ? p[l - 1] : 0); } //dp[index][OR][number of subarrays] = 1 if possible to obtain such partition int dp[N][N]; ll excluded; bool check(ll k, int n, vector<ll>& a, int A, int B) { for(int i = 0;i < N; ++i) for(int j = 0;j < N; ++j) dp[i][j] = 0; dp[0][0] = 1; for(int i = 1; i <= n; ++i) { for(int j = 0;j < i; ++j) { ll s = sum(j, i - 1); if((s & excluded) || (s & (1LL << k))) continue; for(int x = 0;x < n; ++x) { dp[i][x + 1] |= dp[j][x]; } } } for(int j = A; j <= B; ++j) { if(dp[n][j]) return true; } return false; } void solve() { ll n, A, B; cin >> n >> A >> B; vector<ll> a(n); for(int i = 0;i < n; ++i) { cin >> a[i]; p[i] = (i ? p[i - 1] : 0) + a[i]; } ll ans = 0; for(ll pw = 62; pw >= 0; --pw) { if(check(pw, n, a, A, B)) { excluded += (1LL << pw); } else { ans += (1LL << pw); } } cout << ans << "\n"; } int32_t main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t = 1; //cin >> t; while(t--) { solve(); } }
#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...