SHARE
TWEET

FOR ELNUR

Salehisayev Jun 5th, 2020 759 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5. #define pii pair<ll , ll>
  6. #define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  7. #define MAXX 1005
  8.  
  9. ll n , x , y , s;
  10.  
  11. int main()
  12. {
  13.     _FastIO;
  14.     cin >> n;
  15.     vector<pair<ll ,ll> > v;
  16.     for(ll i = 0; i < n; i++){
  17.         cin >> x >> y;
  18.         v.push_back({y , x});
  19.     }
  20.     cin >> s;
  21.     sort(v.begin() , v.end());
  22.     for(ll i = 0; i < n; i++){
  23.         x = v[i].second;
  24.         y = v[i].first;
  25.         s -= x;
  26.         if(s <= 0){
  27.             cout << y << endl;
  28.             return 0;
  29.         }
  30.     }
  31.     return 0;
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top