Codeforces-Level Statistics

山再高,往上爬,总能登顶;
路再长,走下去,定能到达。

Codeforces-Level Statistics

题目描述

Polycarp has recently created a new level in this cool new game Berlio Maker 85 and uploaded it online. Now players from all over the world can try his level.All levels in this game have two stats to them: the number of plays and the number of clears. So when a player attempts the level, the number of plays increases by 1. If he manages to finish the level successfully then the number of clears increases by 1 as well. Note that both of the statistics update at the same time (so if the player finishes the level successfully then the number of plays will increase at the same time as the number of clears).
Polycarp is very excited about his level, so he keeps peeking at the stats to know how hard his level turns out to be.
So he peeked at the stats n times and wrote down n pairs of integers — (p1,c1),(p2,c2),…,(pn,cn), where pi is the number of plays at the i-th moment of time and ci is the number of clears at the same moment of time. The stats are given in chronological order (i.e. the order of given pairs is exactly the same as Polycarp has written down).
Between two consecutive moments of time Polycarp peeked at the stats many players (but possibly zero) could attempt the level.
Finally, Polycarp wonders if he hasn’t messed up any records and all the pairs are correct. If there could exist such a sequence of plays (and clears, respectively) that the stats were exactly as Polycarp has written down, then he considers his records correct.
Help him to check the correctness of his records.
For your convenience you have to answer multiple independent test cases.

输入

The first line contains a single integer T (1≤T≤500) — the number of test cases.
The first line of each test case contains a single integer n (1≤n≤100) — the number of moments of time Polycarp peeked at the stats.
Each of the next n lines contains two integers pi and ci (0≤pi,ci≤1000) — the number of plays and the number of clears of the level at the i-th moment of time.
Note that the stats are given in chronological order.

输出

For each test case print a single line.
If there could exist such a sequence of plays (and clears, respectively) that the stats were exactly as Polycarp has written down, then print “YES”.
Otherwise, print “NO”.
You can print each letter in any case (upper or lower).

Sample Input

6
3
0 0
1 1
1 2
2
1 0
1000 3
4
10 1
15 2
10 2
15 2
1
765 432
2
4 4
4 3
5
0 0
1 0
1 0
1 0
1 0

Sample Outout

NO
YES
NO
YES
NO
YES

Hint

In the first test case at the third moment of time the number of clears increased but the number of plays did not, that couldn’t have happened.
The second test case is a nice example of a Super Expert level.
In the third test case the number of plays decreased, which is impossible.
The fourth test case is probably an auto level with a single jump over the spike.
In the fifth test case the number of clears decreased, which is also impossible.
Nobody wanted to play the sixth test case; Polycarp’s mom attempted it to make him feel better, however, she couldn’t clear it.

题目大意

输入比赛次数和得分情况,你得分一次只能的一分,所以你不可能得分增长的比场次多,而且也不可以出现负增长等不合理情况,问这些数据是否合理,如果合理请输出YES否则NO

题目解析
这题就是判断条件是关键,首先不能小于之前的然后也不能出现自己得分比场次还多的,也不能增长的nm离谱的就可以,详情看代码注释。🦆🦆🦆.

AC时间到

#include<algorithm>
#include<iostream>
#include<string.h>
#include<utility>
#include<stdio.h>
#include<vector>
#include<string>
#include<math.h>
#include<cmath>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#pragma warning(disable:4244)
#define PI 3.1415926536
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll ll_inf = 9223372036854775807;
const int int_inf = 2147483647;
const short short_inf = 32767;
const char char_inf = 127;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll read() {
	ll c = getchar(), Nig = 1, x = 0;
	while (!isdigit(c) && c != '-')c = getchar();
	if (c == '-')Nig = -1, c = getchar();
	while (isdigit(c))x = ((x << 1) + (x << 3)) + (c ^ '0'), c = getchar();
	return Nig * x;
}
inline void out(ll a)
{
	if (a < 0)putchar('-'), a = -a;
	if (a >= 10)out(a / 10);
	putchar(a % 10 + '0');
}
ll qpow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1)res = (res * x) % mod;
		x = (x * x) % mod; n >>= 1;
	}
	return res;
}
#define Floyd for(int k = 1; k <= n; k++)for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)
#define read read()
int main()
{
	int n = read;
	while (n--)
	{
		bool SW = 1;
		int m = read;
		m--;
		int tempa = read, tempb = read;
		if(tempb>tempa)SW=0;
		while (m--)
		{
			int a = read, b = read;
			if (a<tempa||b<tempb||a-tempa<b-tempb||b>a)SW = 0;
			else//不能负增长,不能增长的离谱,不能出现矛盾就OK
			{
				tempa = a;
				tempb = b;
			}
		}
		if (SW)puts("YES");
		else puts("NO");
	}
} 

By-轮月

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Round moon

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值