QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#422469 | #2070. Heavy Stones | 5k_sync_closer | WA | 0ms | 3640kb | C++14 | 859b | 2024-05-27 14:51:04 | 2024-05-27 14:51:08 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
int n, a[200050], f[5050][5050];
signed main()
{
// freopen("freight.in", "r", stdin);
// freopen("freight.out", "w", stdout);
scanf("%lld", &n);
for (int i = 1; i <= n; ++i)
scanf("%lld", a + i);
for (int l = 0; l < n; ++l)
{
for (int r = n + 1; r > l + 1; --r)
{
f[l][r] = 1e18;
if (l != 0)
f[l][r] = min(f[l][r], a[l] * (l + n - r) + f[l - 1][r]);
if (r != n + 1)
f[l][r] = min(f[l][r], a[r] * (l + n - r) + f[l][r + 1]);
if (l == 0 && r == n + 1)
f[l][r] = 0;
}
}
for (int i = 1; i <= n; ++i)
printf("%lld ", a[i] * (n - 1) + f[i - 1][i + 1]);
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3640kb
input:
5 2 1 3 5 4
output:
22 21 24 33 38
result:
wrong answer 1st lines differ - expected: '35 35 36 43 49', found: '22 21 24 33 38 '