Problem p02696 (C++) — buggy submission, verdict: Time Limit Exceeded

/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll, ll> mll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
#define sf(n) scanf("%lld", &n)
#define sff(n, m) scanf("%lld %lld", &n, &m)
#define sfff(n, m, r) scanf("%lld %lld %lld", &n, &m, &r)
#define sfs(n) scanf("%s", n)
#define pf(n) printf("%lld\\n", n)
#define pff(n, m) printf("%lld %lld\\n", n, m)
#define pfff(n, m, r) printf("%lld %lld %lld\\n", n, m, r)
#define pfs(n) printf("%s\\n", n)
#define pfcs(i, n) printf("Case %lld: %lld\\n", i, n)
#define pb push_back
#define prf printf
#define inf 2e18
#define low -1000000000000
#define PI acos(-1.0)
#define rep1(i, n) for (i = 1; i < n; i++)
#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(i, a, n) for (i = a; i < n; i++)
#define repe1(i, n) for (i = 1; i <= n; i++)
#define repe0(i, n) for (i = 0; i <= n; i++)
#define repe(i, a, n) for (i = a; i <= n; i++)
#define endl "\\n"
#define FAST                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define fr freopen("input.txt", "r", stdin)
#define fw freopen("output.txt", "w", stdout)

int main() {
  ll i, n, t, k, j, x = 0, y = 0, m;
  ll a, b;
  cin >> a >> b >> n;
  /*ll ans=  0;
  m = min(a,b);
  m = min(m,n);
  for(i=1;i<=100;i++)
  {
      x = ((a*i)/b) - (a*(i/b));
      cout<<x<<endl;
      ans = max(ans,x);
  }
  cout<<ans<<endl;*/
  if (b - 1 <= n) {
    i = b - 1;
    x = ((a * i) / b) - (a * (i / b));
  } else {
    i = n;
    x = ((a * i) / b) - (a * (i / b));
  }
  cout << x << endl;
  return 0;
}


Error: TLE

Fixed submission:

/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll, ll> mll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
#define sf(n) scanf("%lld", &n)
#define sff(n, m) scanf("%lld %lld", &n, &m)
#define sfff(n, m, r) scanf("%lld %lld %lld", &n, &m, &r)
#define sfs(n) scanf("%s", n)
#define pf(n) printf("%lld\\n", n)
#define pff(n, m) printf("%lld %lld\\n", n, m)
#define pfff(n, m, r) printf("%lld %lld %lld\\n", n, m, r)
#define pfs(n) printf("%s\\n", n)
#define pfcs(i, n) printf("Case %lld: %lld\\n", i, n)
#define pb push_back
#define prf printf
#define inf 2e18
#define low -1000000000000
#define PI acos(-1.0)
#define rep1(i, n) for (i = 1; i < n; i++)
#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(i, a, n) for (i = a; i < n; i++)
#define repe1(i, n) for (i = 1; i <= n; i++)
#define repe0(i, n) for (i = 0; i <= n; i++)
#define repe(i, a, n) for (i = a; i <= n; i++)
#define endl "\\n"
#define FAST                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define fr freopen("input.txt", "r", stdin)
#define fw freopen("output.txt", "w", stdout)

int main() {
  ll i, n, t, k, j, x = 0, y = 0, m;
  ll a, b;
  cin >> a >> b >> n;
  ll ans = 0;
  m = min(n, 200000000LL);
  for (i = 1; i <= m; i++) {
    ans = max(ans, ((a * i) / b) - (a * (i / b)));
  }
  cout << ans << endl;
  return 0;
}