Submission #247651

# Submission time Handle Problem Language Result Execution time Memory
247651 2020-07-11T19:37:48 Z davi_bart Rice Hub (IOI11_ricehub) C++14
0 / 100
8 ms 384 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
typedef long long ll;
//#define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int besthub(int R, int L, int X[], long long B){
  int sx=0,dx=R+1;
  while(sx<dx-1){
    int m=(sx+dx)/2;
    ll tot=0;
    ll mi=1e18;
    int pos=m/2;
    for(int i=0;i<m;i++){
      tot+=abs(X[i]-X[pos]);
    }
    mi=min(mi,tot);
    for(int i=m;i<R;i++){
      pos++;
      tot-=X[pos-1]-X[i-m];
      tot+=m/2*(X[pos]-X[pos-1]);
      tot-=(m)/2*(X[pos]-X[pos-1]);
      tot+=X[i]-X[pos];
      mi=min(mi,tot);
    }
    if(mi<=B)sx=m;
    else dx=m;
  }
  return sx;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -