题目
题意:
你有一个序列 ,一个序列 ,这两个序列要满足 增加的小于 且不能下降, 。
思路:
题意弄懂了,基本上做起来就没什么问题了,列几个 就行了。
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef vector<int> veci;
typedef vector<ll> vecl;
typedef pair<int, int> pii;
template <class T>
inline void read(T &ret) {
char c;
int sgn;
if (c = getchar(), c == EOF) return ;
while (c != '-' && (c < '0' || c > '9')) c = getchar();
sgn = (c == '-') ? -1:1;
ret = (c == '-') ? 0:(c - '0');
while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
ret *= sgn;
return ;
}
inline void out(int x) {
if (x > 9) out(x / 10);
putchar(x % 10 + '0');
}
int main() {
int t, n;
read(t);
while (t--) {
read(n);
int max1 = 0, max2 = 0;
bool flag = false;
for (int i = 0; i < n; i++) {
int x, y;
read(x), read(y);
if (x < y || x < max1 || y < max2 || y - max2 > x - max1) flag = true;
max1 = x;
max2 = y;
}
if (flag) printf("NO\n");
else printf("YES\n");
}
return 0;
}