Submission #41418

#TimeUsernameProblemLanguageResultExecution timeMemory
41418NurlykhanBali Sculptures (APIO15_sculpture)C++14
50 / 100
221 ms748 KiB
#include <bits/stdc++.h> #define pii pair<int, int> #define f first #define s second #define pb push_back #define mp make_pair #define ll long long #define ld long double #define sz(v) int(v.size()) #define all(v) v.begin(), v.end() #define vec vector<int> #define dead not_bad #define bad gooood #define left not_right #define y1 what using namespace std; const int N = (int) 2e3 + 10; const int M = (int) 2000 + 100; const ll LINF = (ll) 2e18; const int INF = (int) 1e9 + 7; const int ALPHA = 26; const int mod = INF; const double PI = 3.14159265359; const ld EPS = (ld) 1e-12; const int nx[4] = {0, 0, -1, 1}; const int ny[4] = {1, -1, 0, 0}; int n, L, R; ll a[N]; int dp[N]; ll get_sum(int l, int r) { return a[r] - a[l - 1]; } void upd(int &x, int y) { x = min(x, y); } bool check(ll x, ll y, int i) { x |= (1LL << i) - 1; x = ~x; if ((x & y) > 0) { return false; } return true; } bool can(int id, ll val) { dp[0] = 0; for (int r = 1; r <= n; r++) { dp[r] = R + 1; for (int l = 1; l <= r; l++) { if (check(val, get_sum(l, r), id)) dp[r] = min(dp[r], dp[l - 1] + 1); } } return dp[n] <= R; } int main() { #define fn "teams" #ifdef witch freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #else //freopen(fn".in", "r", stdin); //freopen(fn".out", "w", stdout); #endif cin >> n >> L >> R; for (int i = 1; i <= n; i++) { cin >> a[i]; a[i] += a[i - 1]; } ll val = 0; for (int bits = 60; bits >= 0; bits--) { if (!can(bits, val)) { val |= (1LL << bits); } } cout << val; 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...