123456789101112131415161718192021222324252627 |
- #include<bits/stdc++.h>
- using namespace std;
- int main() {
- int T;
- cin>>T;
- while(T--) {
- int n;
- cin>>n;
- vector<pair<int,int>> a(n);
- for(int i=0; i<n; i++)cin>>a[i].first>>a[i].second;
- sort(a.begin(),a.end(),[](pair<int,int> a,pair<int,int> b)->bool {
- return a.second-a.first<b.second-b.first;
- });
- bool flag=true;
- int tot=0;
- for(auto p:a) {
- if(p.first+tot<p.second) {
- flag=false;
- break;
- }
- tot+=p.first;
- }
- cout<<(flag?"YES":"NO")<<endl;
- }
-
- return 0;
- }
|