#include "ricehub.h"
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,m,l,r,mid,i;
ll b,x[nmax],s[nmax];
int ok(int k,int md)
{
for(int i=k;i<=n;i++)
{
ll tot=-(s[i-md+1]-s[i-k])+1LL*(i-md+1-i+k)*x[md]+s[i]-s[i-md+1]-1LL*(i-i+md-1)*x[md];
if(tot<=b)return 1;
}
return 0;
}
int besthub(int N,int m,int y[],ll B)
{
//freopen("sol.in","r",stdin);
//freopen("sol.out","w",stdout);
//ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
b=B;
n=N;
for(i=1;i<=n;i++)
{
x[i]=y[i-1];
s[i]=s[i-1]+x[i];
}
l=1,r=n;
while(l<=r)
{
mid=(l+r)/2;
if(ok(mid,(mid/2)+1))l=mid+1;
else r=mid-1;
}
if(ok(l-1,(l-1)/2+1))return max(l-1,1);
else return 1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
888 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |