Guest User

Untitled

a guest
Jan 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define REP(i, n) for(int i = 0; i < n; i++)
  4. #define ALL(a) (a).begin(),(a).end()
  5.  
  6. int main() {
  7. ios::sync_with_stdio(false);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. int n, HP;
  12. cin >> n >> HP;
  13. vector<int> a(n), b(n);
  14. REP(i, n) cin >> a[i] >> b[i];
  15.  
  16. sort(ALL(b), greater<int>());
  17. int amax = *std::max_element(ALL(a));
  18. int ans = 0;
  19. REP(i, n) {
  20. if (HP <= 0 || b[i] < amax) break;
  21. HP -= b[i];
  22. ans++;
  23. }
  24.  
  25. if (HP > 0) ans += (HP + amax - 1) / amax;
  26. cout << ans << endl;
  27. return 0;
  28. }
Add Comment
Please, Sign In to add comment