Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- #define pii pair<ll , ll>
- #define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
- #define MAXX 1005
- ll n , x , y , s;
- int main()
- {
- _FastIO;
- cin >> n;
- vector<pair<ll ,ll> > v;
- for(ll i = 0; i < n; i++){
- cin >> x >> y;
- v.push_back({y , x});
- }
- cin >> s;
- sort(v.begin() , v.end());
- for(ll i = 0; i < n; i++){
- x = v[i].second;
- y = v[i].first;
- s -= x;
- if(s <= 0){
- cout << y << endl;
- return 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement