| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 468598 | Maurimuri80 | Rice Hub (IOI11_ricehub) | C++14 | 1088 ms | 588 KiB | 
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 <cmath>
#include <vector>
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
  vector<long long> ac(R + 1);
  ac[0] = 0;
  
  for (int i = 1; i < ac.size(); i++){
    ac[i] = ac[i-1] + X[i-1];
  }
  int min,max,med;
  min = 1;
  max = R;
  
  while (true)
  {
    if (min == max)
    {
      return min;
    }
    med = (min+max)/2;
    //hallamos la mitad de los posible y no posible
    bool  possible = false;
    for (int i = 0; i <= R - med; i++)
    {
      int izq = i;
      int der = i + med - 1;
      int mid = (izq + der) / 2;
      long long aux =(mid - izq);
      long long aux2 = (der - mid);
      long long rm = X[mid];
      long long sum = ((aux - aux2) * rm) - (ac[mid] - ac[izq]) + (ac[der + 1] - ac[mid + 1]);
      if (sum <= B)
      {
        possible = true;
        break;
      }
    }
    if (possible == true)
    {
      min = med;
    }else{
      max = med-1;
    }
  }
  
    
  return 1;
}
Compilation message (stderr)
| # | 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... | ||||
