QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#702257#5435. Clamped Sequencesurenjamts#WA 0ms3620kbC++17683b2024-11-02 15:34:532024-11-02 15:34:53

Judging History

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

  • [2024-11-02 15:34:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2024-11-02 15:34:53]
  • 提交

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;
    int ans = 0;
    auto check = [&](int l, int r){
    	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);
	};
    for(int it : a){
    	for(int i = -5; i <= 5; i++){
    		  check(it - i, it - i + d);
    		  check(it + i, it + i - d);
		}
	}
	
	cout << ans << '\n';
    
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3620kb

input:

8 3
3 1 4 1 5 9 2 6

output:

18

result:

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