제출 #1124765

#제출 시각아이디문제언어결과실행 시간메모리
1124765mmdrzadaBali Sculptures (APIO15_sculpture)C++17
71 / 100
1095 ms836 KiB
#include <bits/stdc++.h> using namespace std; #define int long long typedef vector<int> vi; typedef vector<char> vc; typedef pair<int, int> pii; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; #define sep ' ' #define F first #define S second #define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define pb push_back #define kill(x) {cout << x << endl;return;} #define sz(x) int(x.size()) #define SP(x) setprecision(x) #define mod(x) (1ll*x%M+M)%M #define pq priority_queue #define mid (l+r)/2 // #define mid2 (l+r+1)/2 #define pll pair<ll, ll> #define REP(i, k) for (int i = 0 ; i < k ; i ++) #define MP make_pair #define us unordered_set const int INF = 1e9+10; const int N = 2e3+10; const int lgn = 63; ll n, a, b; ll y[N]; bitset<N> dp[N]; bool f(int x, int ut) { REP(i, n+1) REP(j, n+1) dp[i][j] = false; dp[0][0] = true; dp[0] <<= 1; for(int i = 1 ; i <= n ; i ++) { ll s = 0; for(int k = i ; k >= 1; k --) { s += y[k]; if ((s>>ut) > (x>>ut)) break; if (!((0ll | (s>>ut) | (x>>ut)) == (x>>ut))) continue; dp[i] |= dp[k-1]; } dp[i] <<= 1; } // for(int i = 1 ; i <= n ; i ++) { // ll s = 0; // for(int k = i ; k >= 1 ; k --) { // s += y[k]; // if ((s>>ut) > (x>>ut)) break; // if (((0ll | (s>>ut) | (x>>ut)) == (x>>ut))) { // dp[i] |= dp[k-1]; // break; // } // } // dp[i] <<= 1; // } for(int i = a+1 ; i <= b+1 ; i ++) { if (dp[n][i]) return true; } return false; } void solve() { cin >> n >> a >> b; for(int i = 1 ; i <= n ; i ++) cin >> y[i]; ll fixed = 0; for(int i = lgn ; i >= 0 ; i --) { if (!f(fixed, i)) fixed += 1ll<<i; } cout << fixed << endl; } // check MAXN int32_t main() { fastIO; solve(); 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...