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

#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 // 10^12
#define MOD 10000007      // 10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  // os << '{';
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  uli a, b, c, h, k, n, w, x, ans = 0, count = 0;
  cin >> a >> b >> n;
  // vector<unsigned lli> f(n + 1);
  // for (unsigned lli i = 0; i <= n; i++)
  // {
  //   unsigned lli e = i / b;
  //   unsigned lli d = (a * i) / b;
  //   if (e <= 0)
  //   {
  //     f[i] = d;
  //   }
  //   else
  //   {
  //     x = d - a * e;
  //     f[i] = x;
  //   }
  // }
  // cout << f << endl;
  // cout << MAX(f) << endl;
  if (n >= b) {
    x = b - 1;
  } else {
    x = n;
  }
  unsigned lli e = x / b;
  unsigned lli d = (a * x) / b;
  x = d - a * e;
  cout << x << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 // 10^12
#define MOD 10000007      // 10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  // os << '{';
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  uli a, b, c, h, k, n, w, x, ans = 0, count = 0;
  cin >> a >> b >> n;
  vector<unsigned lli> f(n + 1);
  for (unsigned lli i = 0; i < n; i++) {
    unsigned lli e = i / b;
    unsigned lli d = (a * i) / b;
    if (e <= 0) {
      f[i] = d;
    } else {
      x = d - a * e;
      f[i] = x;
    }
  }
  cout << MAX(f) << endl;
}