#include<stdio.h> #include<iostream> #include<cstdlib> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<vector> #include<cmath> #include<stack> using namespace std; struct jihe { int first; int end; int cha; }; jihe str[1000]; bool cmp(jihe a, jihe b) { return a.first < b.first; } int main() { int n; cin >> n; while (n--) { int flag = 1; int c; cin >> c; for (int y = 0; y < c; y++) { cin >> str[y].first >> str[y].end; str[y].cha = str[y].end - str[y].first; } sort(str, str + c, cmp); int max = str[0].cha; for (int i = 1; i < c; i++) { if (str[i].cha > max) { max = str[i].cha; } } for (int i = 0; i < c-1; i++) { if (str[i].first + max > str[i + 1].first) { flag = 0; break; } } if (flag == 1) { cout << "YES" << endl; } else { cout << "NO" << endl; } } return 0; } |
Double click to view unformatted code.