CF4B.Before an Exam
普及-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Tomorrow Peter has a Biology exam. He does not like this subject much, but d days ago he learnt that he would have to take this exam. Peter's strict parents made him prepare for the exam immediately, for this purpose he has to study not less than minTimei and not more than maxTimei hours per each i -th day. Moreover, they warned Peter that a day before the exam they would check how he has followed their instructions.
So, today is the day when Peter's parents ask him to show the timetable of his preparatory studies. But the boy has counted only the sum of hours sumTime spent him on preparation, and now he wants to know if he can show his parents a timetable sсhedule with d numbers, where each number sсhedulei stands for the time in hours spent by Peter each i -th day on biology studies, and satisfying the limitations imposed by his parents, and at the same time the sum total of all schedulei should equal to sumTime .
明天皮特将要考生物。他并不很喜欢生物,但在 d 天前他得知他将不得不参加此次考试。皮特严厉的父母勒令他立即复习,因此他在第 i 天将需要学习不少于 minTimei 小时,不多于 maxTimei 小时。他们同时警告皮特:考试前一天,他将被检查他复习的完成情况。
因此,今天皮特的父母会要求他展示他考前复习的学习时间表。然而,他只记录这 d 天以来他复习所用的总计用时 sumTime(小时).现在他希望知道他能否给他的父母展示一份时间表,包含 d 个数,每个数 schedulei 表示皮特第 i 天在复习生物上的用时(单位为小时),并应满足上文提及的要求。
输入格式
The first input line contains two integer numbers d,sumTime ( 1<=d<=30,0<=sumTime<=240 ) — the amount of days, during which Peter studied, and the total amount of hours, spent on preparation. Each of the following d lines contains two integer numbers minTimei,maxTimei ( 0<=minTimei<=maxTimei<=8 ), separated by a space — minimum and maximum amount of hours that Peter could spent in the i -th day.
第一行包含两个数:d,sumTime。
(1≤d≤30,0≤sumTime≤240),意义如上所述。
接下来 d 行,每行两个数:minTimei,maxtimei,两个数之间有一个空格,意义如上。(0≤minTimei≤maxTimei≤8)
输出格式
In the first line print YES, and in the second line print d numbers (separated by a space), each of the numbers — amount of hours, spent by Peter on preparation in the corresponding day, if he followed his parents' instructions; or print NO in the unique line. If there are many solutions, print any of them.
如果有解,在单独一行输出 YES
,换行,输出任意一种满足上文要求的解。如果无解,在单独一行中输出 NO
。
Translated by @B_1168, @ivyjiao, @bye_wjx。
输入输出样例
输入#1
1 48 5 7
输出#1
NO
输入#2
2 5 0 1 3 5
输出#2
YES 1 4