-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.cpp
More file actions
56 lines (55 loc) · 1.1 KB
/
A.cpp
File metadata and controls
56 lines (55 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,n;
cin>>t;
while(t--)
{
cin>>n;
int a[n][2];
for(int i=0;i<n;i++)
{
cin>>a[i][0]>>a[i][1];
}
bool b=true;
for(int i=0;i<n;i++)
{
if(a[i][1]>a[i][0])
{
b=false;
break;
}
if(i+1<n)
{
if(a[i+1][0]<a[i][0] || a[i+1][1]<a[i][1])
{
b=false;
break;
}
if(a[i+1][1]>a[i][1] && a[i+1][0]<=a[i][0])
{
b=false;
break;
}
int d1=a[i+1][1]-a[i][1];
int d2=a[i+1][0]-a[i][0];
if(d1>d2)
{
b=false;
break;
}
}
}
if(b)
{
cout<<"YES";
}
else
{
cout<<"NO";
}
cout<<endl;
}
return 0;
}