QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#768804#5435. Clamped SequenceFalse0099#WA 0ms3556kbC++201.1kb2024-11-21 14:34:242024-11-21 14:34:25

Judging History

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

  • [2024-11-21 14:34:25]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3556kb
  • [2024-11-21 14:34:24]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
int INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;
typedef pair<int, int> PII;
void init()
{
}
void solve()
{
    int n, d;
    cin >> n >> d;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int res = 0;
    for (int i = 1; i <= n; i++)
    {
        int maxx = a[i];
        int minn = max(0ll, a[i] - d);
        vector<int> b = a;
        int sum = 0;
        for (int i = 1; i <= n; i++)
        {
            if (a[i] < minn)
            {
                b[i] = minn;
            }
            else if (a[i] <= maxx)
            {
                b[i] = a[i];
            }
            else
            {
                b[i] = maxx;
            }
            if (i >= 2)
            {
                sum += abs(b[i] - b[i - 1]);
            }
        }
        res = max(res, sum);
    }
    cout << res << endl;
}
signed main()
{
    ios::sync_with_stdio(false), cin.tie(0);
    int t;
    t = 1;
    //    cin>>t;
    init();
    while (t--)
    {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

8 3
3 1 4 1 5 9 2 6

output:

15

result:

ok 1 number(s): "15"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3556kb

input:

2 1
-1000000000 1000000000

output:

1000000000

result:

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