#include "ricehub.h"
#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
int besthub(int R, int L, int X[], long long B)
{
ll ans=1;
ll plus=R;
while(plus!=1)
{
if(ans!=1)
break;
bool pre=false;
ll curr=0;
//cout<<'\n';
for(int i=0;i<=R-plus;i++)
{
ll med;
if(!pre)
{
med=(i+i+plus)/2;
for(int j=i;j<i+plus;j++)
curr+=abs(X[med]-X[j]);
pre=true;
}
else
{
curr-=abs(X[i-1]-X[med]);
med++;
ll dif=abs(X[med]-X[med-1]);
curr=curr+abs(i-med)*dif;
curr=curr-(plus-med)*dif;
curr+=(X[med]-X[i+plus-1]);
}
//cout<<curr<<' ';
if(curr<=B)
{
ans=plus;
break;
}
}
plus--;
}
//cout<<'\n'<<ans<<'\n';
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
115 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |