제출 #568547

#제출 시각아이디문제언어결과실행 시간메모리
568547Ooops_sorryBali Sculptures (APIO15_sculpture)C++14
71 / 100
1091 ms396 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ld double #define ll long long mt19937 rnd(51); const int K = 42; signed main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif // LOCAL ios_base::sync_with_stdio(0); cin.tie(0); int n, x, y; cin >> n >> x >> y; vector<ll> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } ll res = (1LL << K) - 1; for (int b = K - 1; b >= 0; b--) { res -= (1LL << b); vector<vector<bool>> dp(n + 1, vector<bool>(n + 1)); dp[0][0] = 1; for (int i = 0; i < n; i++) { ll sum = 0; for (int j = i; j < n; j++) { sum += a[j]; if ((sum | res) == res) { for (int f = 0; f < n; f++) { if (dp[i][f]) { dp[j + 1][f + 1] = 1; } } } } } bool good = 0; for (int i = x; i <= y; i++) { if (dp[n][i]) { good = 1; } } if (!good) res += (1LL << b); } cout << res << 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...