QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#401780#5435. Clamped Sequencexjt05RE 0ms0kbC++23725b2024-04-29 12:52:162024-04-29 12:52:17

Judging History

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

  • [2024-04-29 12:52:17]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-04-29 12:52:16]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<string.h>
#include<queue>
#include<deque>
#include<vector>
#include<map>
#include<set>
#pragma GCC optimize(3,"Ofast","inline")
#define endl "\n"
using namespace std;
typedef long long ll;
ll n,m,a[5200],u=0;
ll check(ll x)
{
	ll ans=0,d=0,f=0,os=0;
	ll o=x+m;
	for(ll i=2;i<=n;i++)
	{
		ll z;
	if(a[i]<=x)
	z=x;
	else if(a[i]>=o)
	z=o;
	else z=a[i];
	ll r;
	if(a[i-1]<=x)
	r=x;
	else if(a[i-1]>=o)
	r=o;
	else r=a[i-1];
	os+=abs(r-z);
	} 
	u=max(u,os);
}
int main()
{
	set<ll>q;
	cin>>n>>m;
for(ll i=1;i<=n;i++) 
{
cin>>a[i];
q.insert(a[i]);
}
for(auto t:q)
{
	check(t);
}
cout<<u<<endl;
}

詳細信息

Test #1:

score: 0
Runtime Error

input:

8 3
3 1 4 1 5 9 2 6

output:


result: