Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define REP(i, n) for(int i = 0; i < n; i++)
- #define ALL(a) (a).begin(),(a).end()
- int main() {
- ios::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- int n, HP;
- cin >> n >> HP;
- vector<int> a(n), b(n);
- REP(i, n) cin >> a[i] >> b[i];
- sort(ALL(b), greater<int>());
- int amax = *std::max_element(ALL(a));
- int ans = 0;
- REP(i, n) {
- if (HP <= 0 || b[i] < amax) break;
- HP -= b[i];
- ans++;
- }
- if (HP > 0) ans += (HP + amax - 1) / amax;
- cout << ans << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment