This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
#define endl "\n"
#define x first
#define y second
#define pii pair<int,int>
typedef long long int ll;
vector<int> v;
int besthub(int R, int L, int X[], long long B)
{
int n=R;
ll w=B;
v.resize(n+1);
for(int i=0; i<n; i++) {
v[i+1]=X[i];
}
int mx=0;
for(int idx=1; idx<=n; idx++) {
vector<pii> l,r;
int cur=0;
int curv=0;
for(int i=idx+1; i<=n; i++) {
curv+=v[i]-v[idx];
cur++;
r.push_back({curv,cur});
}
r.push_back({0,0});
l.push_back({0,0});
cur=0;
curv=0;
for(int i=idx-1; i>=0; i--) {
curv+=abs(v[i]-v[idx]);
cur++;
l.push_back({curv,cur});
}
int ans=0;
for(pii u:l) {
for(pii v:r) {
if(u.x+v.x<=w) {
ans=max(ans,u.y+v.y);
}
}
}
ans++;
mx=max(mx,ans);
}
return mx;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |