Problem p02598 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
#pragma region DEBUG
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\\'' << x << '\\''; }
void __print(const char *x) { cerr << '\\"' << x << '\\"'; }
void __print(const string &x) { cerr << '\\"' << x << '\\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V> void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T> void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x)
    cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\\n"; }
template <typename T, typename... V> void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v))
    cerr << ", ";
  _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)                                                            \\
  cerr << "[" << #x << "] = [";                                                \\
  _print(x)
#else
#define debug(x...)
#endif
#pragma endregion DEBUG
#define MOD 1000000007
#define MAX 5000005
#define endl "\\n"
lli arr[MAX];
lli n, k;
bool evaluate(lli mid) {
  lli ctr = 0;
  for (lli i = 0; i < n; i++) {
    lli a = arr[i] % mid ? arr[i] / mid + 1 : arr[i] / mid;
    ctr += (a - 1);
  }
  return ctr <= k;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli t;
  t = 1;
  while (t--) {
    lli hi = 1000000005;
    lli low = 0;
    cin >> n >> k;
    for (lli i = 0; i < n; i++) {
      cin >> arr[i];
    }
    while (hi - low > 1) {
      lli mid = (hi + low) / 2;
      if (mid == 0) {
        hi = 1;
        break;
      }
      if (evaluate(mid)) {
        hi = mid;
      } else {
        low = mid;
      }
    }
    cout << hi << endl;
  }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
#pragma region DEBUG
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\\'' << x << '\\''; }
void __print(const char *x) { cerr << '\\"' << x << '\\"'; }
void __print(const string &x) { cerr << '\\"' << x << '\\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V> void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T> void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x)
    cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\\n"; }
template <typename T, typename... V> void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v))
    cerr << ", ";
  _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)                                                            \\
  cerr << "[" << #x << "] = [";                                                \\
  _print(x)
#else
#define debug(x...)
#endif
#pragma endregion DEBUG
#define MOD 1000000007
#define MAX 5000005
#define endl "\\n"
lli arr[MAX];
lli n, k;
bool evaluate(lli mid) {
  lli ctr = 0;
  for (lli i = 0; i < n; i++) {
    lli a = arr[i] % mid ? arr[i] / mid + 1 : arr[i] / mid;
    ctr += (a - 1);
  }
  return ctr <= k;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli t;
  t = 1;
  while (t--) {
    lli hi = 1000000005;
    lli low = -1;
    cin >> n >> k;
    for (lli i = 0; i < n; i++) {
      cin >> arr[i];
    }
    while (hi - low > 1) {
      lli mid = (hi + low) / 2;
      if (evaluate(mid)) {
        hi = mid;
      } else {
        low = mid;
      }
    }
    cout << hi << endl;
  }
}