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<iostream>
#include "ricehub.h"
using namespace std;
long long prefixy[100100];
long long mam[100100];
long long oblicz(int x,int y)
{
int srodek=(x+y)/2;
long long wynik_pomoc=mam[srodek]*(srodek-x)-(prefixy[srodek-1]-prefixy[x-1]);
long long wynik_pom=(prefixy[y]-prefixy[srodek])-mam[srodek]*(y-srodek);
return wynik_pomoc+wynik_pom;
}
int besthub(int n,int l,int tak[],long long b)
{
long long wynik=0,j=1,wynik_pom;
for(int i=0;i<n;i++)
mam[i+1]=tak[i];
for(int i=1;i<=n;i++)
{
prefixy[i]=prefixy[i-1];
prefixy[i]+=mam[i];
}
for(int i=1;i<=n;i++)
{
wynik_pom=oblicz(i,j+1);
while(j<n && wynik_pom<=b)
{
j++;
wynik_pom=oblicz(i,j+1);
}
if((j-i+1)>wynik)
wynik=(j-i+1);
}
return wynik;
}
# | 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... |