Submission #1107641

# Submission time Handle Problem Language Result Execution time Memory
1107641 2024-11-01T19:05:26 Z Lincito_31 Rice Hub (IOI11_ricehub) C++17
17 / 100
10 ms 3408 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
int besthub(int R, int L, int X[], long long B)
{
  vll psum(R+1);
  psum[0]=0;
  psum[1]=X[0];
  for(int i=2;i<=R;i++){
    psum[i]=psum[i-1]+X[i-1];
  }
  int iz=0,de=0;
  int can=1;
  bool xd=false;
  while(iz<R && !xd){
    de=max(de,iz);
    int mid=(iz+de)/2;
    ll sum=(ll)((ll)X[mid]*(mid-iz)-(ll)(psum[mid]-psum[iz]));
    sum+=(ll)((ll)psum[de+1]-(ll)psum[mid+1]-(ll)X[mid]*(de-mid));
    while(sum<=B){
        de++;
        if(de>=R){
            xd=true;
            break;
        }
      sum=(ll)((ll)X[mid]*(mid-iz)-(ll)(psum[mid]-psum[iz]));
      sum+=(ll)((ll)psum[de+1]-(ll)psum[mid+1]-(ll)X[mid]*(de-mid));
    }
    can=max(can,de-iz);
    //cout << iz << " " << de << endl;
    iz++;
  }
  return can;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 0 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 592 KB Output is correct
2 Correct 2 ms 592 KB Output is correct
3 Correct 10 ms 3408 KB Output is correct
4 Incorrect 9 ms 3408 KB Output isn't correct
5 Halted 0 ms 0 KB -