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

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i, n) for (ll i = 0; i < n; i++)

#define all(a) (a).begin(), (a).end()
#define exist(s, e) (s.find(e) != s.end())
#define dbg(x) cout << #x << " is " << x << endl;
#define pt(x) cout << x << "\\n"
#define pts(x) cout << x << " "

#define mp make_pair
#define pb push_back
#define f first
#define s second

#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007

#define fast                                                                   \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define test                                                                   \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll, ll> mll;
typedef set<ll> sl;

//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt = 2e5 + 5;
string a[lmt];

int main() {

  //    #ifndef ONLINE_JUDGE
  //    freopen("../input.txt", "r", stdin);
  //    freopen("../output.txt", "w", stdout);
  // #endif
  fast ll th, ts, ah, as;
  cin >> th >> ts >> ah >> as;
  while (1) {
    ah -= ts;
    if (ah <= 0) {
      pt("Yes");
      return 0;
    }

    th -= as;
    if (th <= 0) {
      pt("No");
      return 0;
    }
  }
}

/*

//

*/

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i, n) for (ll i = 0; i < n; i++)

#define all(a) (a).begin(), (a).end()
#define exist(s, e) (s.find(e) != s.end())
#define dbg(x) cout << #x << " is " << x << endl;
#define pt(x) cout << x << "\\n"
#define pts(x) cout << x << " "

#define mp make_pair
#define pb push_back
#define f first
#define s second

#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007

#define fast                                                                   \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define test                                                                   \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll, ll> mll;
typedef set<ll> sl;

//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt = 1e5 + 5;

int main() {

  //    #ifndef ONLINE_JUDGE
  //    freopen("../input.txt", "r", stdin);
  //    freopen("../output.txt", "w", stdout);
  // #endif
  //    fast

  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  while (!(c == 0 || a == 0)) {
    c = c - b;
    a = a - d;
  }
  if (c == 0)
    pt("Yes");
  else
    pt("No");
}

/*

//

*/