#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { int t; int n; cin >> t; for (int i = 0; i < t; i++) { cin >> n; //n个陷阱 vector<vector<int>> trap(n); int flag = 0; int max_distance = 0; //陷阱间的最大距离 int begin, end; for (int j = 0; j < n; j++) { cin >> begin >> end; //陷阱开始,结束 max_distance = max(max_distance, end - begin); trap[j].push_back(begin); trap[j].push_back(end); } for (int j = 0; j < n - 1; j++) { if (trap[j][0] + max_distance > trap[j + 1][0]) { flag = 1; break; } } if (flag == 1) cout << "NO" << endl; else cout << "YES" << endl; } } |
Double click to view unformatted code.