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代码:

 #include<iostream>
#include<cstdio> using namespace std; int main()
{
int mintime[]={},maxtime[];
int n,sum;
cin>>n>>sum;
int i,j;
for(i=;i<=n;i++){
cin>>mintime[i%n]>>maxtime[i%n];
sum-=mintime[i%n];
}
if(sum<){cout<<"NO"<<endl;return ;}
if(sum==){
cout<<"YES"<<endl;
for(i=;i<=n;i++)cout<<mintime[i%n]<<" ";
cout<<endl;return ;
}
i=;
int k=sum,s=;
while(){
if(mintime[i]<maxtime[i]){
mintime[i]++;
sum--;
if(sum==){
cout<<"YES"<<endl;
for(j=;j<=n;j++)cout<<mintime[j%n]<<" ";
cout<<endl;return ;
}
}
if(k==sum){
s++;
if(s==n+)break;
}
else {k=sum;s=;}
i++;
i%=n;
}
cout<<"NO"<<endl;
return ;
}

B题 Before an Exam的更多相关文章

  1. EGener2四则运算出题器

    项目源码: https://git.coding.net/beijl695/EGener2.git (代码纯属原创,设计细节不同,请思量) 项目发布后,由于期间各种事情,耽搁至最后一天交付.这次的项目 ...

  2. jloi2017(shoi2017?)六省联考酱油记

    Day -n 听说了4.22.4.23的省选,而且还是六省联考. 压力山大. 尽管我只是一名高一的simple OIer,在省选到来之前,心里还是很紧张的. 毕竟自己也知道南方dalao们都是神犇,像 ...

  3. 2018 ACM-ICPC青岛现场赛 B题 Kawa Exam 题解 ZOJ 4059

    题意:BaoBao正在进行在线考试(都是选择题),每个题都有唯一的一个正确答案,但是考试系统有m个bug(就是有m个限制),每个bug表示为第u个问题和第v个问题你必须选择相同的选项,题目问你,如果你 ...

  4. noi题库(noi.openjudge.cn) 1.7编程基础之字符串T21——T30

    T21:单词替换 描述 输入一个字符串,以回车结束(字符串长度<=100).该字符串由若干个单词组成,单词之间用一个空格隔开,所有单词区分大小写.现需要将其中的某个单词替换成另一个单词,并输出替 ...

  5. Java IO流题库

    一.    填空题 Java IO流可以分为   节点流   和处理流两大类,其中前者处于IO操作的第一线,所有操作必须通过他们进行. 输入流的唯一目的是提供通往数据的通道,程序可以通过这个通道读取数 ...

  6. OCJP(1Z0-851) 模拟题分析(一)11

    Exam : 1Z0-851 Java Standard Edition 6 Programmer Certified Professional Exam 以下分析全都是我自己分析或者参考网上的,定有 ...

  7. ocp 1Z0-042 1-60题解析

    1. Because of a power outage,instance failure has occurred. From what point in the redo log does rec ...

  8. URAL 2056 Scholarship 水题

    ScholarshipTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.a ...

  9. Exam 70-462 Administering Microsoft SQL Server 2012 Databases 复习帖

    好吧最近堕落没怎么看书,估计这个月前是考不过了,还是拖到国庆之后考试吧.想着自己复习考试顺便也写点自己的复习的概要,这样一方面的给不准备背题库的童鞋有简便的复习方法(好吧不被题库的同学和我一样看MSD ...

随机推荐

  1. GL应用方面

    1.图和表 2.计算机辅助设计CAD 3.虚拟现实环境 4.数据可视化 5.教学与培训(基于VR) 6.计算机艺术 7.娱乐 8.图像处理 9.用户界面

  2. dev Gridcontrol根据其cell里面的值显示不同颜色

    要改变cell值得颜色 需要用到cellTemplate和convert <DataTemplate x:Key="PercentageCellColorTemplate"& ...

  3. pymongo数据报表脚本

    最近打算将平时自己的一些小工具整理整理,由于一直使用python写脚本,而且数据库一直使用MongoDB,所以直接使用pymonogo驱动数据库做一些报表生成的小脚本,此次的脚本主要针对每个月中公司业 ...

  4. HTML5历史管理

    边看视频边做的练习,随机显示数字,分别使用history和hash来实现历史管理 <!doctype html> <html> <head> <meta ch ...

  5. Docker 基本管理

    镜像: Docker 运行容器前需要本地存在对应的镜像,如果镜像不存在本地,Docker 会从镜像仓库下载(默认是 Docker Hub 公共注册服务器中的仓库). 由于官方镜像pull很慢 我们这边 ...

  6. 如何获取本机IP

    GetLocalHost 直接通过InetAddress.getLocalHost()来获取,其主要逻辑如下 InetAddress.getLocalHost(): String hostname = ...

  7. 对dpkg: error processing package xxx (--configure) 的处理

    这个问题是在在安装Deepdive时候碰到的,具体来说在执行 sudo apt-get update碰到的sudo mv /var/lib/dpkg/info/ /var/lib/dpkg/info_ ...

  8. AngularJs应用

    引用angularjs文件 AngularJS 应用组成如下:View(视图), 即 HTML.Model(模型), 当前视图中可用的数据.Controller(控制器), 即 JavaScript ...

  9. ping 计算机全名,返回的不是IP地址

    今天想看一下机子的IP地址,结果关闭局域防火墙后,在命令行中使用ping 计算机全名,返回的不是IP地址 其实,这也是一种IP地址,IP6地址 原因:默认情况下,win7以上的操作系统,ping 计算 ...

  10. push类型消息中间件-消息发布者(二)

    1.消息发布者声明 我们以spring的方式来声明一个消息发布者: <bean id="operateLogsMessageManager" class="com. ...