Submission #70623

# Submission time Handle Problem Language Result Execution time Memory
70623 2018-08-23T07:44:44 Z doowey Rice Hub (IOI11_ricehub) C++14
0 / 100
1000 ms 528 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll ab(ll x){
  return max(x, -x);
}

int besthub(int n, int L, int X[], ll B){  
  int l = 1, r = n;
  int k;
  bool ok;
  int med;
  ll sum = 0;
  while(l < r){
    k = (l + r)/2;
    ok = false;
    for(int i = 0;i <= n-k;i ++ ){
      med = (i + k - 1) / 2;
      sum = 0;
      for(int j = 0;j < k;j ++ ){
        sum += ab(X[i + j] - X[med]);
      }
      if(sum <= B)
        ok = true;
    }
    if(ok)
      l = k;
    else
      r = k - 1;
  }
  return l;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Execution timed out 1077 ms 484 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 484 KB Output is correct
2 Correct 3 ms 484 KB Output is correct
3 Execution timed out 1087 ms 484 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 484 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 528 KB Time limit exceeded
2 Halted 0 ms 0 KB -