Submission #655653

# Submission time Handle Problem Language Result Execution time Memory
655653 2022-11-05T05:41:31 Z Trumling Rice Hub (IOI11_ricehub) C++14
17 / 100
13 ms 656 KB
#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,l,r;
l=1;
r=R;
bool ok=false;
while(l<r)
{

ok=false;
plus=(l+r)/2;
bool pre=false;
ll curr=0;

for(int i=0;i<=R-plus;i++)
{
ll med;
if(!pre)
{
med=(i+i+plus-1)/2;
for(int j=i;j<i+plus;j++)
    curr+=abs(X[med]-X[j]);
 
pre=true;
}
else
{
    med++;
    ll dif=abs(X[med]-X[med-1]);
    curr+=abs(i-med)*dif;
    curr-=(plus-abs(i-med-1))*dif;
    curr+=abs(X[med]-X[i+plus-1]);
    curr-=abs(X[med-1]-X[i-1]);
}

if(curr<=B)
{
    ans=max(plus,ans);
    ok=true;
    break;
}

}
if(plus==l || plus==r)
break;
if(ok)
  l=plus;
else
  r=plus;
}
//cout<<'\n'<<ans<<'\n';
return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 368 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Incorrect 13 ms 656 KB Output isn't correct
4 Halted 0 ms 0 KB -