链接:
https://codeforces.com/problemset/problem/1334/A
题意:
游戏设计者会不断更新两个记录,一个数游玩次数,一个是通关次数,通关以后再玩也会添加游玩次数
给n条记录(随时间更新)判断是否合理(是否有错误)
解:
四个错误
- 游玩次数少于通关次数
- 游玩次数减少
- 通关次数减少
- 通关增量大于游玩增量
模拟,冲!
实际代码:
#include<iostream>
using namespace std;
int main()
{
int T;
cin>>T;
for(int f=1;f<=T;f++)
{
int n;
cin>>n;
int a=0,b=0;
bool ans=1;
for(int i=1;i<=n;i++)
{
int tempa,tempb;
cin>>tempa>>tempb;
if(i==1)
{
if(tempb>tempa) ans=0;
}
else
{
if(tempb<b)
{
ans=0;continue;
}
if(tempa<a)
{
ans=0;continue;
}
if(tempb>tempa)
{
ans=0;continue;
}
if((tempa-a)<(tempb-b))
{
ans=0;continue;
}
}
a=tempa;b=tempb;
}
if(ans) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
限制:
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output