QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#680394 | #5435. Clamped Sequence | zhuge0 | WA | 0ms | 3552kb | C++17 | 1.0kb | 2024-10-26 20:56:27 | 2024-10-26 20:56:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N = 5e6 + 5;
ll n, b, k, m,d;
ll mod = 1e9 + 9;
//ll d[10000005]{},cnt=0;
bool vis[10000005]{};
vector<int> prime;
void solve() {
cin >> n >> d;
vector<ll> arr(n);
for (auto i : arr) cin >> arr[i];
ll ans = 0;
for (int i = 0; i < n; i++)
{
ll l = arr[i], r = arr[i];
for (int i = 1; i < n; i++)
{
auto turn = [&](ll x, ll l, ll r)
{
if (x > r) return r;
else if (x < l) return l;
else return x;
};
ans = max({ ans,(ll)abs(turn(arr[i],l,l + d) - turn(arr[i - 1],l,l + d)),(ll)abs(turn(arr[i],r,r - d) - turn(arr[i - 1],r,r - d)) });
}
}
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
// pre();
int T = 1;
//cin >> T;
while (T--) {
solve();
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3552kb
input:
8 3 3 1 4 1 5 9 2 6
output:
3
result:
wrong answer 1st numbers differ - expected: '15', found: '3'