博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
B题 Before an Exam
阅读量:5772 次
发布时间:2019-06-18

本文共 2150 字,大约阅读时间需要 7 分钟。

Description

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 dnumbers, 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.

Input

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 numbersminTimei, maxTimei (0 ≤ minTimei ≤ maxTimei ≤ 8), separated by a space — minimum and maximum amount of hours that Peter could spent in the i-th day.

Output

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.

Sample Input

Input
1 48 5 7
Output
NO
Input
2 5 0 1 3 5
Output
YES 1 4

题意:

AC代码:

1 #include
2 #include
3 4 using namespace std; 5 6 int main() 7 { 8 int mintime[32]={
0},maxtime[32]; 9 int n,sum;10 cin>>n>>sum;11 int i,j;12 for(i=1;i<=n;i++){13 cin>>mintime[i%n]>>maxtime[i%n];14 sum-=mintime[i%n];15 }16 if(sum<0){cout<<"NO"<
View Code

 

 

转载于:https://www.cnblogs.com/zhangchengbing/p/3233449.html

你可能感兴趣的文章
linux系统终端命令提示符设置(PS1)记录
查看>>
C++运算符重载
查看>>
【Web】URI和URL,及URL的编码
查看>>
宿舍局域网的应用
查看>>
html代码究竟什么用途
查看>>
oracle的substr函数的用法
查看>>
QT 数据库编程四
查看>>
npm下载包时代理配置
查看>>
全球十大理论
查看>>
model.addAttribute("student",student)——渲染
查看>>
JavaWeb开发之普通图片验证码生成技术与算术表达式验证码生成技术
查看>>
python和pywin32实现窗口查找、遍历和点击
查看>>
第二章 概率图模型的基本原理
查看>>
Hadoop HDFS编程 API入门系列之路径过滤上传多个文件到HDFS(二)
查看>>
Nginx反向代理,负载均衡,redis session共享,keepalived高可用
查看>>
CentOS7 yum 安装git
查看>>
sublime text 3浅色主题
查看>>
数据结构之红黑树(三)——删除操作
查看>>
html5视频标签
查看>>
JAVA进阶-注解
查看>>