#include<iostream> using namespace std; //这题其实有点小错误,按照它的意思,每个陷阱是连在一起的,即当前陷阱的结尾是下一个陷阱的开头。 int main() { int t, n; cin >> t; while (t--) { cin >> n; int **arr = new int*[n]; int minstep = -1; for (int i = 0; i < n; i++) { arr[i] = new int[2]; cin >> arr[i][0] >> arr[i][1]; if (arr[i][1]-arr[i][0] > minstep) minstep = arr[i][1] - arr[i][0]; } bool judge = true; for (int i = 0; i < n-1; i++) { if (arr[i][0]+minstep>arr[i+1][0]) { judge = false; break; } } if (judge) cout << "YES" << endl; else cout << "NO" << endl; } return 0; } |
Double click to view unformatted code.