QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#667285#5435. Clamped Sequencethesky12138WA 1ms3644kbC++14705b2024-10-22 22:03:212024-10-22 22:03:28

Judging History

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

  • [2024-10-22 22:03:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3644kb
  • [2024-10-22 22:03:21]
  • 提交

answer

#include <bits/stdc++.h>
//#define int LL
#define INF 2000000000
using namespace std;
typedef long long LL;

const int N = 5e3 + 10;

int a[N];
void solve()
{
    int n, d;
    cin >> n >> d;
    int val = INF;
    for (int i = 1; i <= n; i ++ ) {
        cin >> a[i];
        val = min(a[i], val);
    }

    int l = val, r = val + d;

    a[1] = min(r, a[1]);
    LL ans = 0;
    for (int i = 2; i <= n; i ++ ) {
        a[i] = min(r, a[i]);
        ans += abs(a[i] - a[i - 1]);
    }

    //for (int i = 1; i <= n; i ++ ) cout << a[i] << ' ';

    cout << ans;
}


signed main()
{
    int t = 1;
    while (t -- )
    {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3644kb

input:

8 3
3 1 4 1 5 9 2 6

output:

15

result:

ok 1 number(s): "15"

Test #2:

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

input:

2 1
-1000000000 1000000000

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

2 1000000000
-1000000000 1000000000

output:

1000000000

result:

ok 1 number(s): "1000000000"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3500kb

input:

5000 10000
-10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10...

output:

49990000

result:

ok 1 number(s): "49990000"

Test #5:

score: 0
Accepted
time: 1ms
memory: 3628kb

input:

5000 10000
10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 1...

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 3624kb

input:

5000 2897
8987 9710 547 6523 -4484 8892 7360 7473 -5435 8122 -1396 -9963 -1884 -5758 -2930 2867 -260 -3947 -7915 -2428 4137 -1202 -1874 7205 -2852 -6126 -9346 -8662 2294 -4453 -2430 2424 9434 -112 2906 -169 -9489 -1977 68 -9072 2785 -2258 9710 271 8817 6251 3120 4765 -8449 -6625 2617 -3931 -4024 144...

output:

2024487

result:

wrong answer 1st numbers differ - expected: '7111087', found: '2024487'