제출 #542348

#제출 시각아이디문제언어결과실행 시간메모리
542348bonkBali Sculptures (APIO15_sculpture)C++14
50 / 100
103 ms364 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N4 = 105; const int N5 = 2005; int n, a, b; vector<ll>y; bool dp4[N4][N4]; //st4 (idx, group) int dp5[N5]; //st5 (idx) bool s4(ll x){ memset(dp4, 0, sizeof(dp4)); dp4[0][0] = 1; for(int i = 1; i <= n; i++){ ll sum = 0; for(int j = i; j <= n; j++){ sum += y[j]; if(!(sum & x)){ for(int k = 1; k <= n; k++){ dp4[i][k] |= dp4[j - 1][k - 1]; } } } } for(int i = a; i <= b; i++) if(dp4[n][i]) return 1; return 0; } bool s5(ll x){ memset(dp5, 0x3f, sizeof(dp5)); dp5[0] = 0; for(int i = 0; i <= n; i++){ ll sum = 0; for(int j = i + 1; j <= n; j++){ sum += y[j]; if(!(sum & x)) dp5[j] = min(dp5[j], dp5[i] + 1); } } return (dp5[n] <= b); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> a >> b; y.resize(n + 1); for(int i = 1; i <= n; i++) cin >> y[i]; ll ret = 0; for(int i = 50; i >= 0; i--){ if(a == 1){ if(s5((1LL<<i) + ret)) ret += (1LL<<i); } else{ if(s4((1LL<<i) + ret)) ret += (1LL<<i); } } ll ans = (1LL<<51) - 1 - ret; cout << ans << endl; return 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...