QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#74208 | #5435. Clamped Sequence | XKError | WA | 2ms | 3516kb | C++14 | 680b | 2023-01-31 09:01:24 | 2023-01-31 09:01:25 |
Judging History
answer
#include <bits/stdc++.h>
#define maxn 10005
#define int long long
using namespace std;
int n, d;
int a[maxn];
int b[maxn];
int tot;
int w[maxn];
signed main() {
scanf("%lld%lld", &n, &d);
for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
for (int i = 1; i <= n; i++) {
w[++tot] = a[i];
w[++tot] = a[i] - d;
}
int ans = 0;
for (int p = 1; p <= tot; p++) {
int l = w[p], r = l + d;
// cout<<l<<" "<<r<<endl;
for (int i = 1; i < n; i++) {
b[i] = max(a[i], l);
b[i] = min(b[i], r);
}
int res = 0;
for (int i = 1; i < n; i++) res += abs(b[i] - b[i + 1]);
ans = max(ans, res);
}
printf("%lld\n", ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3516kb
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: 2ms
memory: 3516kb
input:
2 1 -1000000000 1000000000
output:
1000000000
result:
wrong answer 1st numbers differ - expected: '1', found: '1000000000'