#include<iostream> #include<vector> #include<string> #include <algorithm> #include <math.h> using namespace std; int main() { int t; cin >> t; while (t--){ int n; cin >> n; int l[n]; int r[n]; int m=-1; for (int i = 0; i < n; ++i) { cin >> l[i]; cin >> r[i]; m = max(m,r[i]-l[i]); } bool flag = true; for(int i=0; i<n-1; i++){ if(l[i]+m > l[i+1]){ cout << "NO" <<endl; flag = false; break; } } if(flag){ cout << "YES" << endl; } } } |
Double click to view unformatted code.