Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- long long tab[1000007],n,a,j,w=0,s;
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- cin>>n;
- for(int i=0;i<n;i++)
- {
- cin>>a>>j;
- tab[i]=j-a;
- }
- sort(tab,tab+n);
- for(long long i=0;i<n;i++)
- {
- if(s+tab[i]<=0) s+=tab[i];
- else
- {
- cout<<i;
- return 0;
- }
- }
- cout<<n;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement