0
点赞
收藏
分享

微信扫一扫

2022.01.27翻译Before an Exam

灵魂跑者 2022-01-27 阅读 74
c++

Before an Exam
题目(https://acs.jxnu.edu.cn/problem/CF4B)描述:
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.

输入:
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.

输出:
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.

样例输入:
1 48
5 7
样例输出:
NO
样例输入:
2 5
0 1
3 5
样例输出:
YES
1 4 

翻译:
Peter明天有生物考试。他非常不喜欢这门学科,但是他d天前得知他必须参加生物考试。Peter严格的父母立马让他为考试做准备,因此他不得不学习,在第i天他至少要学习minTimei 小时且不多于maxTimei 小时。然而,Peter的父母警告Peter说在考试前一天他们会检查他的完成情况。

所以今天就是Peter的父母要求他展示他学习的时间表。但是他只知道他总共学习了sumTime小时,现在他想知道他是否能给他的父母展示合格的有d个数字的时间表sсhedule,每个数字sсhedulei表示Peter在第i天花在生物学习上的时间,并且sсhedulei符合他父母要求的时间,同时每个sсhedulei的和为sumTime。

输入:
第一行包含两个整数d,sumTime(1 ≤ d ≤ 30, 0 ≤ sumTime ≤ 240),d为Peter学习天数,sumTime为Peter学习的总时间。接下来d行,每行包含用一个空格隔开的两个整数 minTimei, maxTimei (0 ≤ minTimei ≤ maxTimei ≤ 8), 分别表示Peter在第i天学习时间的最小值和最大值。
输出:
如果存在这样的时间表,在第一行输出YES,在第二行输出d个数字(用一个空格隔开),每个数字表示Peter在这天学习的时间。如果不存在这样的时间表在第一行输出NO。如果有多个答案,输出任意一个即可。

举报

相关推荐

0 条评论