CF4B.Before an Exam

普及-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Tomorrow Peter has a Biology exam. He does not like this subject much, but dd 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 minTimeiminTime_{i} and not more than maxTimeimaxTime_{i} hours per each ii -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 sumTimesumTime spent him on preparation, and now he wants to know if he can show his parents a timetable sсhedulesсhedule with dd numbers, where each number sсheduleisсhedule_{i} stands for the time in hours spent by Peter each ii -th day on biology studies, and satisfying the limitations imposed by his parents, and at the same time the sum total of all scheduleischedule_{i} should equal to sumTimesumTime .

明天皮特将要考生物。他并不很喜欢生物,但在 dd 天前他得知他将不得不参加此次考试。皮特严厉的父母勒令他立即复习,因此他在第 ii 天将需要学习不少于 minTimeiminTime_i 小时,不多于 maxTimeimaxTime_i 小时。他们同时警告皮特:考试前一天,他将被检查他复习的完成情况。

因此,今天皮特的父母会要求他展示他考前复习的学习时间表。然而,他只记录这 dd 天以来他复习所用的总计用时 sumTimesumTime(小时).现在他希望知道他能否给他的父母展示一份时间表,包含 dd 个数,每个数 scheduleischedule_i 表示皮特第 ii 天在复习生物上的用时(单位为小时),并应满足上文提及的要求。

输入格式

The first input line contains two integer numbers d,sumTimed,sumTime ( 1<=d<=30,0<=sumTime<=2401<=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 dd lines contains two integer numbers minTimei,maxTimeiminTime_{i},maxTime_{i} ( 0<=minTimei<=maxTimei<=80<=minTime_{i}<=maxTime_{i}<=8 ), separated by a space — minimum and maximum amount of hours that Peter could spent in the ii -th day.

第一行包含两个数:d,sumTimed,sumTime

(1d30,0sumTime240)\left(1\le d\le30,0\le sumTime\le240\right),意义如上所述。

接下来 dd 行,每行两个数:minTimei,maxtimeiminTime_i,maxtime_i,两个数之间有一个空格,意义如上。(0minTimeimaxTimei8)\left(0\le minTime_i\le maxTime_i\le8\right)

输出格式

In the first line print YES, and in the second line print dd 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
首页