0
点赞
收藏
分享

微信扫一扫

1.28 Before an Exam

晚安大世界 2022-01-28 阅读 68
c++

描述:

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.

明天Peter有生物考试。他不喜欢这门课,但是d天之前,他得知要考这门课。Peter严厉的父母要求他立刻开始复习这门课,正因如此,他每天学习不能少于最少时间,也不能多余最多时间每个第i天。除此之外,他们还警告Peter在考试前他们会检查他是否遵循他们的计划。

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.

所以,今天是Peter的父母叫他展示他的预料课程表的时间。但是男孩只算了他在准备的总时间,现在他想知道他是否可以给父母展示带有d的时间表,每个数字schedulei表示每第i天Peter在生物学习上花费的时间,并且还能满足他父母的限制,同时总时间要等于sumTime。

输入:

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.

第一行包括2个整数d和sumTime (1 ≤ d ≤ 30, 0 ≤ sumTime ≤ 240)——Peter学习的总天数,和在准备花费的总时间。接下来的d行包含2个整数minTimei和maxTimei(0 ≤ minTimei ≤ maxTimei ≤ 8),用空格分开——在第i天Peter可以学习的最短时间和最长时间。

输出:

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,在第二行输出d个数字(通过空格分开),每个数字表示Peter在相应的时间里花费在准备上的时间;如果不行,输出NO,如果有很多解决方法,任意输出其中一个。

样例输入:

1 48
5 7

样例输出:

NO

样例输入:

2 5
0 1
3 5

样例输出:

YES
1 4 
举报

相关推荐

0 条评论