QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#702257 | #5435. Clamped Sequence | surenjamts# | WA | 0ms | 3620kb | C++17 | 683b | 2024-11-02 15:34:53 | 2024-11-02 15:34:53 |
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;
int ans = 0;
auto check = [&](int l, int r){
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);
};
for(int it : a){
for(int i = -5; i <= 5; i++){
check(it - i, it - i + d);
check(it + i, it + i - d);
}
}
cout << ans << '\n';
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3620kb
input:
8 3 3 1 4 1 5 9 2 6
output:
18
result:
wrong answer 1st numbers differ - expected: '15', found: '18'