Submission #1244227

#TimeUsernameProblemLanguageResultExecution timeMemory
1244227wedonttalkanymoreBali Sculptures (APIO15_sculpture)C++20
71 / 100
5 ms840 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long #define pii pair<ll, ll> #define fi first #define se second const ll N = 2e3 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 41; int n, l, r; int a[N]; int dp[N][N]; void reset() { for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) dp[i][j] = false; } // cout << "ok: " << flush; dp[0][0] = true; } void sub4() { // cout << 11111 << '\n' << flush; // xet den i va da dung j doan int res = (1LL << lim) - 1; // cout << res; for (int mask = lim - 1; mask >= 0; mask--) { reset(); res -= (1LL << mask); for (int i = 0; i <= n; i++) { for (int j = 0; j <= i; j++) { if (!dp[i][j]) continue; int sum = 0; for (int k = i + 1; k <= n; k++) { sum += a[k]; if ((sum & res) == sum) { // sum la con cua res dp[k][j + 1] = true; } } } } int need = 0; for (int i = l; i <= r; i++) need |= dp[n][i]; res += !need * (1LL << mask); } cout << res << '\n'; } signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> l >> r; for (int i = 1; i <= n; i++) cin >> a[i]; // cout << n << ' ' << l << ' ' << r << '\n'; if (n <= 100) { // cout << 111 << '\n' << flush; sub4(); } 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...