Submission #687631

# Submission time Handle Problem Language Result Execution time Memory
687631 2023-01-26T17:03:17 Z beedle Rice Hub (IOI11_ricehub) C++17
100 / 100
15 ms 2508 KB
#include "ricehub.h"
#include <iostream>

int besthub(int R, int L, int X[], long long B)
{
  long long cs[R];
  cs[0]=X[0];
  for(int i=1;i<R;i++)
  cs[i]=cs[i-1]+X[i];
  long long lo=1;
  long long hi=R;
  long long best=1;
  while(lo<=hi)
  {
    long long mid=(lo+hi)/2;
    bool possible=false;
    for(int i=0;i<R;i++)
    if(i+mid-1<R)
    {
      long long pivot=i+mid/2;
      long long value=-(cs[pivot-1]-(i==0?0:cs[i-1]))+cs[i+mid-1]-cs[pivot]-X[pivot]*(i+mid-1-pivot)+X[pivot]*(pivot-1-(i-1));
      if(value<=B)
      possible=true;
    } 
    if(possible)
    best=mid, lo=1+mid;
    else
    hi=mid-1;
  }
  return best;
}

// signed main() 
// {
//   int X[]={1,2,10,12,14};
//   std::cout<<besthub(5,20,X,6);
// }
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 296 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 312 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 308 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 312 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 552 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 14 ms 2452 KB Output is correct
4 Correct 13 ms 2500 KB Output is correct
5 Correct 9 ms 1196 KB Output is correct
6 Correct 7 ms 1236 KB Output is correct
7 Correct 15 ms 2124 KB Output is correct
8 Correct 12 ms 2216 KB Output is correct
9 Correct 6 ms 1108 KB Output is correct
10 Correct 6 ms 1092 KB Output is correct
11 Correct 13 ms 2508 KB Output is correct
12 Correct 13 ms 2500 KB Output is correct
13 Correct 6 ms 1248 KB Output is correct
14 Correct 7 ms 1236 KB Output is correct
15 Correct 10 ms 1916 KB Output is correct
16 Correct 12 ms 1948 KB Output is correct
17 Correct 12 ms 2192 KB Output is correct
18 Correct 11 ms 2216 KB Output is correct
19 Correct 13 ms 2348 KB Output is correct
20 Correct 12 ms 2388 KB Output is correct