QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#702118 | #5435. Clamped Sequence | surenjamts# | WA | 0ms | 3616kb | C++17 | 619b | 2024-11-02 15:20:30 | 2024-11-02 15:20:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
signed main(){
int n , d;
cin >> n >> d;
vector<int> a(n);
for(auto &i : a) cin >> i;
auto b = a;
sort(b.begin(), b.end());
int ans = 0;
for(int it : b){
int l = it - 1;
int r = l + d;
auto v = a;
for(auto &i : v){
if(i < l) i = l;
else if(i > r) i = r;
}
int sum = 0;
for(int i = 1; i < n; i++){
sum += abs(v[i] - v[i - 1]);
}
ans = max(ans, sum);
}
cout << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
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: 3560kb
input:
2 1 -1000000000 1000000000
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3616kb
input:
2 1000000000 -1000000000 1000000000
output:
999999999
result:
wrong answer 1st numbers differ - expected: '1000000000', found: '999999999'