| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 222912 | Bruteforceman | 수열 (APIO14_sequence) | C++11 | 2081 ms | 5752 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int a[100010];
int n, k;
long long pre[100010];
long long dp[202][100010], opt[202][100010];
const long long inf = 1e17;
int main() {
scanf("%d %d", &n, &k);
k += 1;
for(int i = 1; i <= n; i++) {
scanf("%d", a + i);
}
for(int i = 1; i <= n; i++) {
pre[i] = pre[i - 1] + a[i];
}
long long sum = pre[n];
for(int j = 1; j <= n; j++) {
dp[0][j] = -inf;
}
dp[0][0] = 0;
for(int i = 1; i <= k; i++) {
for(int j = 0; j <= n; j++) {
dp[i][j] = -inf;
for(int x = 0; x < j; x++) {
long long cost = dp[i - 1][x] +
(sum - pre[j] + pre[x]) * (pre[j] - pre[x]);
if(cost > dp[i][j]) {
dp[i][j] = cost;
opt[i][j] = x;
}
}
}
}
printf("%lld\n", dp[k][n] / 2);
int cur = n;
int cnt = k;
while(cnt) {
cur = opt[cnt--][cur];
if(cur) printf("%d ", cur);
}
puts("");
return 0;
}
컴파일 시 표준 에러 (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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
