제출 #846078

#제출 시각아이디문제언어결과실행 시간메모리
846078tuan13Bali Sculptures (APIO15_sculpture)C++14
0 / 100
8 ms63324 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const int ar = 2e3 + 5; int n, a[ar], P, Q; ll dp[ar][ar], suf[ar][ar], sum[ar]; ll get(int l, int r) { return sum[r] - sum[l - 1]; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> P >> Q; for(int i = 1; i <= n; ++i) { cin >> a[i]; sum[i] = sum[i - 1] + a[i]; } memset(dp, 0x3f, sizeof(dp)); memset(suf, 0x3f, sizeof(suf)); for(int i = 1; i <= n; ++i) { dp[i][0] = sum[i]; for(int j = 1; j < i; ++j) { for(int k = 1; k < i; ++k) { dp[i][j] = min(dp[i][j], dp[k][j - 1] | get(k + 1, i)); } } } for(int i = n; i >= 1; --i) { suf[i][0] = get(i, n); for(int j = 1; j < (n - i + 1); ++j) { for(int k = n; k > i; --k) { suf[i][j] = min(suf[i][j], suf[k][j - 1] | get(i, k - 1)); } } } ll ans = 1e18; for(int i = 1; i <= n; ++i) { for(int j = 0; j <= Q; ++j) { for(int k = 0; k <= Q; ++k) { if(j + k - 1 >= P - 1 && j + k - 1 <= Q - 1) ans = min(ans, dp[i][j] | suf[i + 1][k]); } } } cout << ans; }
#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...