# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
505053 | amukkalir | Bali Sculptures (APIO15_sculpture) | C++17 | 16 ms | 31820 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define fi first
#define se second
const ll INF = LLONG_MAX;
const int nax = 2000;
ll dp[nax+5][nax+5];
ll p[nax+5];
int n;
ll f (int rem, int idx) {
if(idx==n+1) return (rem==0)?0:INF;
if(rem<=0 && idx != n+1) return INF;
ll &res = dp[rem][idx];
if(~res) return res;
res = INF;
for(int i=idx; i<=n; i++) {
res = min(res, p[i]-p[idx-1] | f(rem-1, i+1));
}
return res;
}
signed main () {
int a, b;
scanf("%d%d%d", &n, &a, &b);
for(int i=1; i<=n; i++) {
ll y; scanf("%lld", &y);
p[i] = p[i-1] + y;
}
ll ans = INF;
memset(dp, -1, sizeof dp);
for(int i=a; i<=b; i++) {
ans = min(ans, f(i, 0));
//cout << i << " " << f(i, 0) << endl;
}
printf("%lld", ans);
}
/*
YES
3 1 3
YES
1
NO
YES
5 5 4 1 4 5
*/
컴파일 시 표준 에러 (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... |