CF4B.Before an Exam

普及-

通过率:0%

时间限制:0.50s

内存限制:64MB

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 minTime__i and not more than maxTime__i 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сhedule__i 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 schedule__i should equal to sumTime.

明天彼得有一场生物考试。他并不太喜欢这门学科,但 d 天前他就得知自己必须参加这场考试。彼得严厉的父母要求他立即开始备考;为此,他每天(第 i 天)的学习时间不得少于 minTime__i 小时,且不得超过 maxTime__i 小时。此外,父母还警告彼得:考试前一天他们会检查他是否遵守了这些规定。

因此,今天正是彼得的父母要求他出示备考学习时间表的日子。然而,彼得只计算出了自己总共花费的复习时间之和 sumTime,现在他想知道:是否存在一个包含 d 个数的时间表 schedule,使得其中每个数 schedule__i 表示彼得在第 i 天用于生物学习的小时数,该时间表满足父母设定的所有限制条件,并且所有 schedule__i 的总和恰好等于 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 minTime__i, maxTime__i (0 ≤ minTime__i ≤ maxTime__i ≤ 8), separated by a space — minimum and maximum amount of hours that Peter could spent in the i-th day.

第一行输入包含两个整数 dd 和 sumTime\text{sumTime}(1≤d≤301 \leq d \leq 30,0≤sumTime≤2400 \leq \text{sumTime} \leq 240)—— 分别表示彼得学习的天数以及他总共用于备考的小时数。接下来的 dd 行中,每行包含两个整数 minTimei\text{minTime}_i 和 maxTimei\text{maxTime}_i(0≤minTimei≤maxTimei≤80 \leq \text{minTime}_i \leq \text{maxTime}_i \leq 8),以空格分隔——分别表示彼得在第 ii 天可能花费的最少与最多小时数。

输出格式

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 个数字(以空格分隔),每个数字表示彼得在对应天数中按照父母的指示所花费的准备时间(单位:小时);或者仅在唯一一行中输出 NO。若存在多个解,输出任意一个即可。

输入输出样例

  • 输入#1

    1 48
    5 7

    输出#1

    NO
  • 输入#2

    2 5
    0 1
    3 5

    输出#2

    YES
    1 4

输入解题思路,AI测评打分。不知道怎么写?

首页