Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 552 Bytes

kill_the_monsters.md

File metadata and controls

27 lines (20 loc) · 552 Bytes

C. Kill the Monster

  • amazing approach
  • in O(N) checked the both.
void solve() {
  ll hc, dc, hm, dm, k, w, a;
  cin >> hc >> dc >> hm >> dm >> k >> w >> a;

  for (int i = 0; i <= k; i++) {
    ll new_health = hc + i * a;
    ll new_power = dc + (k - i) * w;

    ll h_damage_m = hm / new_power + (hm % new_power != 0);
    ll m_damage_h = new_health / dm + (new_health % dm != 0);

    if (h_damage_m <= m_damage_h) {
      cout << "YES\n";
      return;
    }
  }
  cout << "NO\n";
}