Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. long long tab[1000007],n,a,j,w=0,s;
  4. int main()
  5. {
  6.     ios_base::sync_with_stdio(0);
  7.     cin.tie(0);
  8.     cin>>n;
  9.     for(int i=0;i<n;i++)
  10.     {
  11.         cin>>a>>j;
  12.         tab[i]=j-a;
  13.        
  14.        
  15.     }
  16.     sort(tab,tab+n);
  17.     for(long long i=0;i<n;i++)
  18.     {
  19.         if(s+tab[i]<=0) s+=tab[i]; 
  20.         else
  21.         {
  22.         cout<<i;
  23.         return 0;  
  24.         }
  25.     }
  26.     cout<<n;
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement