CF939F.Cutlet
提高+/省选-
通过率:0%
时间限制:4.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Arkady wants to have a dinner. He has just returned from a shop where he has bought a semifinished cutlet. He only needs to fry it. The cutlet should be fried for 2_n_ seconds, in particular, it should be fried for n seconds on one side and n seconds on the other side. Arkady has already got a frying pan and turn on fire, but understood that maybe he won't be able to flip the cutlet exactly after n seconds after the beginning of cooking.
Arkady is too busy with sorting sticker packs in his favorite messenger and can flip the cutlet only in some periods of time. Namely, there are k periods of time in which he can do it, the i-th of them is an interval of time from l__i seconds after he starts cooking till r__i seconds, inclusive. Arkady decided that it's not required to flip the cutlet exactly in the middle of cooking, instead, he will flip it several times in such a way that the cutlet will be fried exactly n seconds on one side and n seconds on the other side in total.
Help Arkady and find out if it's possible for him to cook the cutlet, if he is able to flip the cutlet only in given periods of time; and if yes, find the minimum number of flips he needs to cook the cutlet.
阿尔卡季想吃晚饭。他刚从商店买回了一块半成品牛排,只需煎熟即可。这块牛排总共需煎 2n 秒:每面各需煎 n 秒。阿尔卡季已备好平底锅并点着了火,但随即意识到——他可能无法恰好在开始烹饪后的第 n 秒准时翻面。
此时阿尔卡季正忙着在他最喜爱的即时通讯软件中整理贴纸包,因此他只能在某些特定时间段内翻动牛排。具体来说,共有 k 个可翻面的时间段;其中第 i 个时间段为从开始烹饪起第 li 秒至第 ri 秒(含端点)的闭区间。阿尔卡季决定:不必非得在烹饪正中间(即第 n 秒)翻面;他可以通过多次翻面,使得牛排两面各自被煎熟的总时间恰好均为 n 秒。
请帮助阿尔卡季判断:若仅能在给定的时间段内翻面,他是否能成功煎熟牛排?若可以,请找出他所需的最少翻面次数。
输入格式
The first line contains two integers n and k (1 ≤ n ≤ 100 000, 1 ≤ k ≤ 100) — the number of seconds the cutlet should be cooked on each side and number of periods of time in which Arkady can flip it.
The next k lines contain descriptions of these intervals. Each line contains two integers l__i and r__i (0 ≤ l__i ≤ r__i ≤ 2·n), meaning that Arkady can flip the cutlet in any moment starting from l__i seconds after the beginning of cooking and finishing at r__i seconds after beginning of cooking. In particular, if l__i = r__i then Arkady can flip the cutlet only in the moment l__i = r__i. It's guaranteed that l__i > r__i - 1 for all 2 ≤ i ≤ k.
第一行包含两个整数 n 和 k(1≤n≤100000,1≤k≤100)——分别表示牛排每面所需的烹饪时间(单位:秒)以及 Arkady 可以翻转牛排的时间段数量。
接下来的 k 行描述这些时间段。每行包含两个整数 li 和 ri(0≤li≤ri≤2⋅n),表示 Arkady 可以在从开始烹饪起 li 秒到 ri 秒之间的任意时刻翻转牛排。特别地,若 li=ri,则 Arkady 仅能在时刻 li=ri 翻转牛排。保证对所有 2≤i≤k,均有 li>ri−1。
输出格式
Output "Hungry" if Arkady won't be able to fry the cutlet for exactly n seconds on one side and exactly n seconds on the other side.
Otherwise, output "Full" in the first line, and the minimum number of times he should flip the cutlet in the second line.
如果阿尔卡季无法恰好将牛排每面各煎 n 秒,则输出 "Hungry"。
否则,第一行输出 "Full",第二行输出他需要翻面的最少次数。
输入输出样例
输入#1
10 2 3 5 11 13
输出#1
Full 2
输入#2
10 3 3 5 9 10 11 13
输出#2
Full 1
输入#3
20 1 3 19
输出#3
Hungry
说明/提示
In the first example Arkady should flip the cutlet in time moment 3 seconds after he starts cooking and in time moment 13 seconds after he starts cooking.
In the second example, Arkady can flip the cutlet at 10 seconds after he starts cooking.
在第一个例子中,阿尔卡季应在开始烹饪后 3 秒和开始烹饪后 13 秒这两个时刻翻转肉排。
在第二个例子中,阿尔卡季可在开始烹饪后 10 秒翻转肉排。
输入解题思路,AI测评打分。不知道怎么写?