QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#372472#5435. Clamped Sequenceucup-team3294#WA 0ms3500kbC++231.3kb2024-03-31 13:58:172024-03-31 13:58:18

Judging History

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

  • [2024-03-31 13:58:18]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3500kb
  • [2024-03-31 13:58:17]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=5e3+5;
int a[N],b[N];
void solve(){
	int n,ans=0,d,l,r,res=0,sum=0;
	cin>>n>>d;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sum/=n;
	for(int i=1;i<=n;i++) b[i]=a[i]-b[i-1];
	for(int i=1;i<=n;i++) cout<<a[i]-a[i-1]<<" ";
	cout<<"\n";
	for(int i=1;i<=n;i++) cout<<b[i]<<" ";
	for(int i=sum-5000;i<=sum+5000;i++){
		l=i;r=i+d;
		res=0;
		for(int x=1;x<=n;x++){
			if(a[x]<l||a[x]>r){
				if(a[x]<l) b[x]=l;
				else if(a[x]>r) b[x]=r;
			}
			else b[x]=a[x];
		}
		for(int j=2;j<=n;j++){
			res+=abs(b[j]-b[j-1]);
		}
		ans=max(ans,res);
	}
	for(int i=1;i<=n;i++){
		l=a[i];r=a[i]+d;
		res=0;
		for(int x=1;x<=n;x++){
			if(a[x]<l||a[x]>r){
				if(a[x]<l) b[x]=l;
				else if(a[x]>r) b[x]=r;
			}
			else b[x]=a[x];
		}
		for(int j=2;j<=n;j++){
			res+=abs(b[j]-b[j-1]);
		}
		ans=max(ans,res);
	}
	for(int i=1;i<=n;i++){
		l=a[i]-d;r=a[i];
		res=0;
		for(int x=1;x<=n;x++){
			if(a[x]<l||a[x]>r){
				if(a[x]<l) b[x]=l;
				else if(a[x]>r) b[x]=r;
			}
			else b[x]=a[x];
		}
		for(int j=2;j<=n;j++){
			res+=abs(b[j]-b[j-1]);
		}
		ans=max(ans,res);
	}
	cout<<ans<<"\n";
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0); 
	int t;
//	cin>>t;
	while(t--){
		solve();
	}
}

詳細信息

Test #1:

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

input:

8 3
3 1 4 1 5 9 2 6

output:


result:

wrong answer Answer contains longer sequence [length = 1], but output contains 0 elements