import java.util.Scanner; public class Main { static Scanner in = new Scanner(System.in); public static void main(String[] args) { int T=in.nextInt(); for (int i = 0; i < T; i++) { int n = in.nextInt(); int [][] a=new int[n][2]; int maxStep=0; for (int j = 0; j < n; j++) { a[j][0] = in.nextInt(); a[j][1] = in.nextInt(); if (a[j][1]-a[j][0]>maxStep){ maxStep=a[j][1]-a[j][0]; } } //mock int pos=a[0][0]; boolean flag=true; for (int j = 0; j < n-1; j++) { pos=pos+maxStep; if (pos <= a[j + 1][0]) { } else { flag=false; } } if (flag) { System.out.println("YES"); } else { System.out.println("NO"); } } } } |
Double click to view unformatted code.