C - Ideal Holidays
https://atcoder.jp/contests/abc347/tasks/abc347_c
思路
将所有延迟计划时间 % a+b 映射到 区间 [0, a+b]
然后对映射数组排序,
统计最大间距(最大间距可以被安排到 工作日 b),
如果最大间距 大于 b, 则所有延迟计划可以被安排到 假期
Code
int n, a, b; vector<int> d; int main() { cin >> n >> a >> b; int modula = a+b; for(int i=0; i<n; i++){ int temp; cin >> temp; temp %= modula; d.push_back(temp); } sort(d.begin(), d.end()); int maxseg = -1; for(int i=1; i<d.size(); i++){ maxseg = max(maxseg, d[i]-d[i-1]-1); } maxseg = max(maxseg, (a+b - d[d.size()-1] + d[0]-1)); if (maxseg >= b){ cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }
标签:间距,temp,int,modula,Holidays,Ideal From: https://www.cnblogs.com/lightsong/p/18106104