QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#74208#5435. Clamped SequenceXKErrorWA 2ms3516kbC++14680b2023-01-31 09:01:242023-01-31 09:01:25

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-31 09:01:25]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3516kb
  • [2023-01-31 09:01:24]
  • 提交

answer

#include <bits/stdc++.h>

#define maxn 10005
#define int long long

using namespace std;

int n, d;
int a[maxn];
int b[maxn];

int tot;
int w[maxn];

signed main() {
	scanf("%lld%lld", &n, &d);
	for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
	for (int i = 1; i <= n; i++) {
		w[++tot] = a[i];
		w[++tot] = a[i] - d;
	}
	int ans = 0;
	for (int p = 1; p <= tot; p++) {
		int l = w[p], r = l + d;
//		cout<<l<<" "<<r<<endl;
		for (int i = 1; i < n; i++) {
			b[i] = max(a[i], l);
			b[i] = min(b[i], r);
		}
		int res = 0;
		for (int i = 1; i < n; i++) res += abs(b[i] - b[i + 1]);
		ans = max(ans, res);
	}
	printf("%lld\n", ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3516kb

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: 2ms
memory: 3516kb

input:

2 1
-1000000000 1000000000

output:

1000000000

result:

wrong answer 1st numbers differ - expected: '1', found: '1000000000'