제출 #527583

#제출 시각아이디문제언어결과실행 시간메모리
527583SlavicGBali Sculptures (APIO15_sculpture)C++17
37 / 100
23 ms388 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 = 105; ll p[N]; int 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 k = 0;k < n; ++k) { dp[i][k + 1] |= dp[j][k]; } } } for(int j = A; j <= B; ++j) { if(dp[n][j]) return true; } return false; } void solve() { int 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 = 63; 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...