QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#422483#2070. Heavy Stones5k_sync_closerTL 0ms3676kbC++14867b2024-05-27 14:59:252024-05-27 14:59:25

Judging History

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

  • [2024-05-27 14:59:25]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3676kb
  • [2024-05-27 14:59:25]
  • 提交

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 + 1) + f[l - 1][r]);
            if (r != n + 1)
                f[l][r] = min(f[l][r], a[r] * (l + n - r + 1) + 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: 100
Accepted
time: 0ms
memory: 3676kb

input:

5
2 1 3 5 4

output:

35 35 36 43 49 

result:

ok single line: '35 35 36 43 49 '

Test #2:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

10
18 37 81 6 58 99 87 34 75 9

output:

2637 2637 2657 2657 2695 2949 2995 2905 2880 2880 

result:

ok single line: '2637 2637 2657 2657 2695 2949 2995 2905 2880 2880 '

Test #3:

score: -100
Time Limit Exceeded

input:

200000
479735 430060 863649 878892 889364 241972 927862 32858 714406 674598 88114 438434 167733 457299 951288 510096 635193 504974 649221 617914 223711 812277 364169 746142 836563 825312 994240 198961 567906 905208 509572 744710 891294 928176 833980 985385 858440 50835 86130 324862 796245 935992 383...

output:


result: