QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#648063 | #5435. Clamped Sequence | laing2122 | WA | 1ms | 3624kb | C++17 | 1.2kb | 2024-10-17 16:51:51 | 2024-10-17 16:51:55 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<random>
#include<string>
#include<time.h>
#include<cstring>
#include<set>
#include<cmath>
#include<queue>
#define int long long
#define endl '\n'
#define F first
#define S second
#define sz size()
#define B begin()
#define pb push_back
#define D end()
#define pii pair<int,int>
#define ln cout<<'\n'
using namespace std;
typedef long long ll;
const int N=2e6+10;
const int P=1331;
const int mod=1e9+7;
void solve()
{
int n,d;cin>>n>>d;
vector<int>a(n+1),b(n+1);
for(int i=1;i<=n;i++) cin>>a[i];
int ans=0;
for(int i=1;i<=n;i++)
{
int l=a[i];int r=a[i]+d;int op=0;
for(int j=1;j<=n;j++)
{
b[j]=min(r,a[j]);
b[j]=max({op,l,b[j]});
}
int cnt=0;
for(int j=1;j<n;j++)
{
cnt+=abs(b[j+1]-b[j]);
}
ans=max(ans,cnt);
cnt=0;l=max(op,a[i]-d);
r=l+d;
for(int j=1;j<=n;j++)
{
b[j]=min(r,a[j]);
b[j]=max({op,l,b[j]});
}
cnt=0;
for(int j=1;j<n;j++)
{
cnt+=abs(b[j+1]-b[j]);
}
}
cout<<ans;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int tc=1;
//cin>>tc;
while(tc--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3552kb
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: 1ms
memory: 3624kb
input:
2 1 -1000000000 1000000000
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'