fork download
  1. program flappybird;
  2. const Max =100000;
  3. var N, i : Longint;
  4. A, B : array[0..MAX] of int64;
  5. inizio, fine :int64;
  6. uscita:boolean;
  7. begin
  8. (*assign(input, 'input.txt'); reset(input);
  9.   assign(output, 'output.txt'); rewrite(output);*)
  10. readln(N);
  11. for i:=0 to N-1 do readln(A[i],B[i]);
  12. inizio:=A[0]; fine:=B[0]; uscita:=true;
  13. for i:=1 to N-1 do
  14. begin
  15. if (A[i]>=inizio ) and (A[i]<=fine) then begin inizio:=A[i]; if B[i]<=fine then fine:=B[i]; end
  16. else if A[i]>fine then begin uscita:=false; writeln ('NO'); exit; end
  17. else if A[i]<inizio then begin if B[i]<inizio then begin uscita:=false; writeln ('NO'); exit; end
  18. else if (B[i]>=inizio) and (B[i]<=fine) then fine:=B[i];
  19. end;
  20.  
  21. end;
  22. if uscita=true then writeln('YES') ;
  23. end.
Success #stdin #stdout 0.01s 5320KB
stdin
2
1 5
0 4
stdout
YES