# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
270385 | BeanZ | Bali Sculptures (APIO15_sculpture) | C++14 | 16 ms | 768 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define endl '\n'
const int N = 3e6 + 5;
ll dp[2005][2005], a[2005], sum[2005];
bool chk(ll now, ll need){
return ((need & now) == now);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("VietCT.INP", "r")){
freopen("VietCT.INP", "r", stdin);
freopen("VietCT.OUT", "w", stdout);
}
ll n, L, R;
cin >> n >> L >> R;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
ll ans = 2048;
for (int s = 0; s < 2048; s++){
for (int i = 0; i <= n; i++){
for (int j = 0; j <= R; j++){
dp[j][i] = 2048;
}
}
for (int i = 1; i <= n; i++) if (chk(sum[i], s)) dp[1][i] = sum[i];
if (1 >= L) ans = min(ans, dp[1][n]);
for (int i = 2; i <= R; i++){
for (int j = 1; j <= n; j++){
for (int k = 0; k < j; k++){
ll cost = dp[i - 1][k] | (sum[j] - sum[k]);
if (chk(cost, s)){
if (dp[i][j] > cost){
dp[i][j] = cost;
}
}
}
}
if (i >= L) ans = min(ans, dp[i][n]);
}
if (ans != 2048) return cout << s, 0;
}
//cout << ans;
}
/*
6 1 3
8 1 2 1 5 4
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |