QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#702118#5435. Clamped Sequencesurenjamts#WA 0ms3616kbC++17619b2024-11-02 15:20:302024-11-02 15:20:30

Judging History

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

  • [2024-11-02 15:20:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2024-11-02 15:20:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
signed main(){
    int n , d;
    cin >> n >> d;
    vector<int> a(n);
    for(auto &i : a) cin >> i;
    auto b = a;
    sort(b.begin(), b.end());
    int ans = 0;
    for(int it : b){
    	int l = it - 1;
    	int r = l + d;
    	auto v = a;
    	for(auto &i : v){
    		if(i < l) i = l;
    		else if(i > r) i = r;
		}
		int sum = 0;
		for(int i = 1; i < n; i++){
			sum += abs(v[i] - v[i - 1]);
		}
        ans = max(ans, sum);
	}
	
	cout << ans << '\n';
    
}

详细

Test #1:

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

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: 3560kb

input:

2 1
-1000000000 1000000000

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3616kb

input:

2 1000000000
-1000000000 1000000000

output:

999999999

result:

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