QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#768841 | #5435. Clamped Sequence | False0099# | WA | 1ms | 3556kb | C++20 | 1.6kb | 2024-11-21 14:47:38 | 2024-11-21 14:47:40 |
Judging History
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);
int res = 0;
for (int _ = 1; _ <= n; _++)
{
int maxx = a[_];
int minn = a[_] - d;
vector<int> b = a;
int sum = 0;
for (int i = 1; i <= n; i++)
{
if (a[i] < minn)
{
b[i] = minn;
}
if (a[i] >= minn && a[i] <= maxx)
{
b[i] = a[i];
}
if (a[i] > maxx)
{
b[i] = maxx;
}
if (i >= 2)
{
sum += abs(b[i] - b[i - 1]);
}
}
res = max(res, sum);
minn = a[_];
maxx = a[_] + d;
b = a;
sum = 0;
for (int i = 1; i <= n; i++)
{
if (a[i] < minn)
{
b[i] = minn;
}
if (a[i] >= minn && a[i] <= maxx)
{
b[i] = a[i];
}
if (a[i] > maxx)
{
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();
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3556kb
input:
8 3 3 1 4 1 5 9 2 6
output:
0
result:
wrong answer 1st numbers differ - expected: '15', found: '0'