Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int main() {
- int n; ll b;
- cin >> n >> b;
- vector<pair<ll,ll>> a(n);
- for (auto &i : a) {
- cin >> i.first >> i.second;
- }
- sort(a.begin(), a.end());
- ll ans = 0;
- for (auto &i : a) {
- ll t = min(b / i.first, i.second);
- b -= t * i.first;
- ans += t;
- }
- cout << ans << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment