Submission #341841

#TimeUsernameProblemLanguageResultExecution timeMemory
341841egod1537Bali Sculptures (APIO15_sculpture)C++14
21 / 100
19 ms31872 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1000000000LL * 2001LL; int n, a, b; ll arr[2001]; ll dp[2001][2001]; ll solve(int pos, int cnt) { if (pos == n) { if (a <= cnt && cnt <= b) return 0; else return INF; } ll& ret = dp[pos][cnt]; if (ret != -1) return ret; ret = INF; ll sum = 0; for (int i = pos; i < n; i++) { sum += arr[i]; ret = min(ret, solve(i+1, cnt+1)|sum); } return ret; } int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> n >> a >> b; for (int i = 0; i < n; i++) cin >> arr[i]; memset(dp, -1, sizeof(dp)); cout << solve(0, 0); 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...