Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdlib>
- #include<vector>
- #include<algorithm>
- #define long long long
- #define nln '\n'
- using namespace std;
- bool cmp_pair(const pair<long, long> &a, const pair<long, long> &b)
- {
- if (a.first > b.first)
- return 1;
- if (a.first < b.first)
- return 0;
- if (a.second > b.second)
- return 0;
- if (a.second < b.second)
- return 1;
- return 0;
- }
- int main()
- {
- cin.tie(0)->sync_with_stdio(0);
- cout.tie(0)->sync_with_stdio(0);
- //freopen("practice.inp", "r", stdin);
- long n, t;
- cin >> n >> t;
- vector<pair<long, long>> a(n);
- for (auto &i : a)
- cin >> i.first >> i.second;
- // Process
- sort(a.rbegin(), a.rend(), cmp_pair);
- long ans = 0;
- for (long i = 0; i < n; ++i)
- {
- if (t < a[i].first)
- break;
- ++ans;
- t += a[i].second;
- }
- cout << ans << nln;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment