Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define flush cin.ignore(numeric_limits<streamsize>::max(),'\n')
- #define FASTERIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
- #define NL cout<<'\n';
- #define pi acos(-1.0) //3.1415926535897932384626
- #define pb push_back
- #define mk make_pair
- #define mx 100005
- #define EPS 1e-10
- #define dpoint(x) fixed<<setprecision(x)
- typedef long long int ll;
- typedef double dl;
- typedef unsigned long long int ull;
- //Funtions
- template <class T> T digitsum(T n) {T sum = 0; while (n != 0) {sum += n % 10; n /= 10;} return sum;}
- int gcd(int a, int b) { int x ; return x = __gcd(a, b);}
- int lcm(int a, int b) {int y; return y = ((a) * ((b) / gcd(a, b)));}
- // Debugger
- #define gobug 0
- #define debugNS(a,b,c) cout<<a<<b<<c<<endl;
- #define debugN(b) cout<<b<<endl;
- bool cmp(pair<int, int>a, pair<int, int>b) {
- if(a<b)return true;
- return false;
- }
- int main() {
- FASTERIO; //cmt when use scanf & printf ;
- int tt, n; cin>>tt;
- int x,y; cin>>x>>y;
- n = tt;
- vector<pair<int,int>>mp;
- while(tt--){
- int a,b; cin>>a>>b;
- mp.pb({a,b});
- }
- for(int i=0; i<n; i++){
- for(int j=i+1; j<n; j++){
- if(cmp(mp[i],mp[j]))swap(mp[i],mp[j]);
- }
- }
- bool flg = false;
- int boll=0, ric=0, cnt=0;
- for(auto it:mp){
- boll+=it.first;
- ric+=it.second;
- cnt++;
- if(boll >= x && ric>=y){
- flg = true; break;
- }
- }
- if(flg)cout<<cnt<<endl;
- else cout<<-1<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment