#include<iostream> using namespace std; struct data { double bg; double end; double Long; }trap[100]; int main() { int t; cin >> t; while (t--) { int n;//陷阱数量 cin >> n; for (int i = 0; i < n; i++) { cin >> trap[i].bg >> trap[i].end; trap[i].Long = trap[i].end - trap[i].bg; } //初试位置 double local = trap[0].bg; string isScuess = "YES"; for (int j = 0;;j++) { local += trap[0].Long; //最后一个陷阱 if (j == n - 1) { if (local >= trap[j].end)break; else { isScuess = "NO"; break; } } if (local >= trap[j].end&&local <= trap[j+1].bg) { continue; } else { isScuess = "NO"; break; } } if(t!=0) cout << isScuess << endl; else cout << isScuess; } } |
Double click to view unformatted code.