AtCoder abc347 c 求助
  • 板块学术版
  • 楼主peterJr
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/3/30 21:44
  • 上次更新2024/3/31 04:20:19
查看原帖
AtCoder abc347 c 求助
1050776
peterJr楼主2024/3/30 21:44

站外题目求助 题目:

Problem Statement
In the Kingdom of AtCoder, a week consists of A+B days, with the first through A-th days being holidays and the (A+1)-th through (A+B)-th being weekdays.

Takahashi has N plans, and the i-th plan is scheduled Di days later.

He has forgotten what day of the week it is today. Determine if it is possible for all of his N plans to be scheduled on holidays.

代码:

#include <iostream>
#include <algorithm>

using namespace std;

long long n, a, b, d[200007], flag;

int main()
{
	cin >> n >> a >> b;
	for (int i = 0; i < n; ++i) cin >> d[i];
	
	for (int i = 0; i < n; ++i)
	{
		d[i] %= (a + b);
	}
	
	sort(d, d + n);
	long long num = max(0 * 1ll, d[n - 1] - a) - 1;
	while (num++ <= (a + b))
	{
		if (!(d[n - 1] - a - num <= 0 && d[n - 1] - a - num >= -a + 1)) continue;
		else if (!(d[0] - a - num <= 0 && d[0] - a - num >= -a + 1)) continue;
		else 
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	cout << "No" << endl;
	return 0;
}
2024/3/30 21:44
加载中...