QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#706468 | #5435. Clamped Sequence | hejinming983282# | WA | 0ms | 3528kb | C++14 | 1.0kb | 2024-11-03 11:33:33 | 2024-11-03 11:33:34 |
Judging History
answer
// Author : hejinming2012
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define dbg(x) cout << #x " = " << (x) << endl
#define quickio ios::sync_with_stdio(false);
#define quickin cin.tie(0);
#define quickout cout.tie(0);
using namespace std;
inline int read() {
int now = 0, nev = 1; char c = getchar();
while(c < '0' || c > '9') { if(c == '-') nev = -1; c = getchar(); }
while(c >= '0' && c <= '9') { now = (now << 1) + (now << 3) + (c & 15); c = getchar(); }
return now * nev;
}
void write(int x) {
if(x < 0) putchar('-'), x = -x;
if(x > 9) write(x / 10);
putchar(x % 10 + '0');
}
signed main() {
quickio
quickin
quickout
int n, d; cin >> n >> d;
vector <int> a(n + 1);
for(int i = 1; i <= n; i++)
cin >> a[i];
int ans = 0;
for(int i = 1; i <= n; i++) {
int now = 0;
for(int j = i + 1; j <= min(n, i + d + 1); j++)
now += abs(a[j] - a[j - 1]), ans = max(ans, now);
}
write(ans), putchar(10);
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3528kb
input:
8 3 3 1 4 1 5 9 2 6
output:
19
result:
wrong answer 1st numbers differ - expected: '15', found: '19'