fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int n; cin >> n;
  7. vector<int> a(n), b(n);
  8. for (int i = 0; i < n; ++i) {
  9. cin >> a[i] >> b[i];
  10. if (i && max(a[i], a[i-1]) > min(b[i], b[i-1])) {
  11. cout << "NO\n";
  12. return 0;
  13. }
  14. }
  15. cout << "YES\n";
  16. }
  17.  
Success #stdin #stdout 0.01s 5280KB
stdin
3
3 6
2 4
2 6
stdout
YES