QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#422469#2070. Heavy Stones5k_sync_closerWA 0ms3640kbC++14859b2024-05-27 14:51:042024-05-27 14:51:08

Judging History

你现在查看的是最新测评结果

  • [2024-05-27 14:51:08]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3640kb
  • [2024-05-27 14:51:04]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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 '