#include "ricehub.h"
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int n;
ll m;
vl a;
bool f(int x){
ll res,tmp=0;
for(int i=0;i<x/2;i++) tmp-=a[i];
for(int i=x/2+1;i<x;i++) tmp+=a[i];
res=tmp+(x+1)%2*a[x/2];
for(int i=x;i<n;i++){
tmp+=a[i];
tmp-=a[i-(x-1)/2];
tmp+=a[i-x];
tmp-=a[i-x+x/2];
res=min(res,tmp+(x+1)%2*a[x/2]);
}
return res<=m;
}
int besthub(int R, int L, int X[], ll B){
n=R,m=B;
a=vl(n);
for(int i=0;i<n;i++) a[i]=X[i];
int l=1,r=n+1;
while(r-l>1){
int mid=(l+r)/2;
if(f(mid)) l=mid;
else r=mid;
}
return l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |