QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#448907 | #5435. Clamped Sequence | WTR2007 | WA | 63ms | 3984kb | C++14 | 1.3kb | 2024-06-20 11:38:46 | 2024-06-20 11:38:47 |
Judging History
answer
#include<bits/stdc++.h>
#define fi first
#define se second
#define MULT_TEST 0
using namespace std;
typedef long double ldb;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
const int N = 5005;
int a[N], b[N];
inline int read() {
int w = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
w = (w << 1) + (w << 3) + ch - 48;
ch = getchar();
}
return w * f;
}
int n, d;
inline int Calc(int l, int r) {
int ans = 0;
for (int i = 1; i <= n; i++) {
if (a[i] < l) b[i] = l;
else if (a[i] > r) b[i] = r;
else b[i] = a[i];
}
for (int i = 1; i < n; i++) ans += abs(b[i] - b[i + 1]);
return ans;
}
inline void Solve() {
n = read(), d = read();
for (int i = 1; i <= n; i++) a[i] = read();
int ans = 0;
for (int i = 1; i <= n; i++) {
ans = max(ans, Calc(a[i], a[i] + d));
ans = max(ans, Calc(a[i] - d, a[i]));
}
printf("%lld\n", ans);
}
signed main() {
int _ = 1;
#if MULT_TEST
_ = read();
#endif
while (_--) Solve();
return 0;
}
/*
8 3
3 1 4 1 5 9 2 6
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3836kb
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: 3824kb
input:
2 1 -1000000000 1000000000
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
2 1000000000 -1000000000 1000000000
output:
1000000000
result:
ok 1 number(s): "1000000000"
Test #4:
score: 0
Accepted
time: 58ms
memory: 3788kb
input:
5000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10000 10000 -10...
output:
49990000
result:
ok 1 number(s): "49990000"
Test #5:
score: 0
Accepted
time: 62ms
memory: 3980kb
input:
5000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 1...
output:
0
result:
ok 1 number(s): "0"
Test #6:
score: 0
Accepted
time: 63ms
memory: 3984kb
input:
5000 2897 8987 9710 547 6523 -4484 8892 7360 7473 -5435 8122 -1396 -9963 -1884 -5758 -2930 2867 -260 -3947 -7915 -2428 4137 -1202 -1874 7205 -2852 -6126 -9346 -8662 2294 -4453 -2430 2424 9434 -112 2906 -169 -9489 -1977 68 -9072 2785 -2258 9710 271 8817 6251 3120 4765 -8449 -6625 2617 -3931 -4024 144...
output:
7111087
result:
ok 1 number(s): "7111087"
Test #7:
score: 0
Accepted
time: 62ms
memory: 3792kb
input:
5000 6321 -5894 5183 -3582 7556 -2937 2854 -5688 1422 -7283 5712 -3719 3700 -8585 2577 -703 1839 -8871 9819 -1080 6964 -7192 1664 -9414 1863 -3638 7843 -6700 9064 -4209 7225 -2617 180 -9771 401 -3029 7485 -3877 3095 -4176 5830 -1954 8879 -9515 4671 -9834 395 -3489 6706 -5316 9004 -3536 546 -5360 686...
output:
26696461
result:
ok 1 number(s): "26696461"
Test #8:
score: 0
Accepted
time: 62ms
memory: 3860kb
input:
5000 1224 -9995 -9993 -9992 -9990 -9987 -9979 -9977 -9969 -9965 -9963 -9959 -9956 -9944 -9944 -9931 -9930 -9929 -9927 -9926 -9924 -9923 -9921 -9917 -9917 -9907 -9901 -9899 -9890 -9885 -9876 -9871 -9867 -9859 -9859 -9859 -9854 -9854 -9841 -9841 -9836 -9836 -9834 -9831 -9829 -9823 -9823 -9822 -9818 -9...
output:
1224
result:
ok 1 number(s): "1224"
Test #9:
score: -100
Wrong Answer
time: 60ms
memory: 3796kb
input:
5000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 1000000 -1000000 100000...
output:
704032704
result:
wrong answer 1st numbers differ - expected: '4999000000', found: '704032704'