QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#706465 | #5435. Clamped Sequence | hejinming983282# | WA | 0ms | 3652kb | C++14 | 1.0kb | 2024-11-03 11:32:54 | 2024-11-03 11:32:55 |
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); j++)
now += abs(a[j] - a[j - 1]), ans = max(ans, now);
}
write(ans), putchar(10);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3652kb
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: 0ms
memory: 3640kb
input:
2 1 -1000000000 1000000000
output:
2000000000
result:
wrong answer 1st numbers differ - expected: '1', found: '2000000000'