·WA求助 -- 没有样例
查看原帖
·WA求助 -- 没有样例
538761
huays1230楼主2024/1/4 23:16

题目

代码如下

#include<bits/stdc++.h>
#define N 100010
using namespace std;
int n;
string ans[2] = {"NO\n", "YES\n"};

namespace hys
{
	struct node
	{
		int start;
		int endt;
		int tim = (start - endt) / 2 + 1;
		int delta = endt - tim;
	};	
	
	struct node a[N];
	
	bool cmp(node x, node y)
	{
		return x.delta < y.delta;
	}
	
	void input()
	{
		cin >> n;
		if(n == 0)
		{
			exit(0);
		}
		for(int i = 1; i <= n; i++)
		{
			cin >> a[i].start >> a[i].endt;
		}
	}
}

using namespace hys;

int main()
{
	bool flag;
	int i;
	
	while(true)
	{
		hys::input();
		std::sort(a + 1, a + n + 1, hys::cmp);
		flag = true;
		
		for(i = 2; i <= n; i++)
		{
			if(a[i - 1].start + a[i - 1].tim > a[i].endt - a[i].tim)
			{
				flag = false;
				break;
			}
		}
		cout << ans[flag];
	}
	return 0;
}

看似没有问题呀

大佬求条

2024/1/4 23:16
加载中...