-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA.cpp
More file actions
39 lines (36 loc) · 1021 Bytes
/
Copy pathA.cpp
File metadata and controls
39 lines (36 loc) · 1021 Bytes
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
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(),v.end()
#define X first
#define Y second
#define rep(x, y, z) for(ll (z) = (x); (z) < (y); (z)++)
int constexpr N = 1e5;
int constexpr MOD = 1e9 + 7;
int constexpr INF = 1e9;
int main() {
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int tc;
cin >> tc;
auto Solve = []() {
int n;
cin >> n;
vector<pair<int, int>> in(n);
rep (0, n, i) cin >> in[i].X >> in[i].Y;
int lastp = in[0].X, lastc = in[0].Y;
if (lastp < lastc) return cout << "NO\n", 0;
rep (1, n, i) {
int diffp = in[i].X - lastp;
if (in[i].Y - lastc > diffp) return cout << "NO\n", 0;
if (diffp < 0) return cout << "NO\n", 0;
if (in[i].Y - lastc < 0) return cout << "NO\n", 0;
lastp = in[i].X, lastc = in[i].Y;
}
cout << "YES\n";
return 0;
};
while (tc--) {
Solve();
}
return 0;
}