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. VMware安装ubuntu,通过/mnt/hgfs 挂载共享Windows系统文件夹

    网上各种相关的配置说明,但是都没一个完整的,在这里楼主结合实战亲测,这一整套包含各种情况 1.安装VMware tools 2.解压到任意一个文件夹 tar -xzvf VMwareTools**** ...

  2. Linq——Count、Sum、Min、Max、Average

    using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; us ...

  3. JavaScript忍者秘籍——原型

    概要:本篇博客主要介绍JavaScript的原型 1.对象实例化 - 初始化的优先级 初始化操作的优先级如下: ● 通过原型给对象实例添加的属性 ● 在构造器函数内给对象实例添加的属性 在构造器内的绑 ...

  4. 介绍shell脚本

    简单的说shell就是一个包含若干行Shell或者Linux命令的文件.对于一次编写,多次使用的大量命令,就可以使用单独的文件保存下来, 以便日后使用.通常shell脚本以.sh为后缀.在编写shel ...

  5. 特殊函数(__all__)

    python里__all__ 属性分别于模块和包之中的用法 一. 在模块(*.py)中使用意为导出__all__列表里的类.函数.变量等成员,否则将导出modualA中所有不以下划线开头(私有)的成员 ...

  6. Linux常用命令汇总及使用方法(二)之文本编辑器VI

    VI可能是在Linux中使用比较频繁的文本编辑器,如果不能熟练使用VI,在一定程度上会影响工作效率,所以在这里记录一下VI的常用命令及操作方式 在[root@test ~]# vi carrie.tx ...

  7. Fighting For 2017 Season Contest 1

    比赛地址[https://vjudge.net/contest/147011#problem/A].960626 题目一:[http://codeforces.com/problemset/probl ...

  8. sql 针对多个id或名称的分割和组合

    开发中经常遇到把多个id拼接在一起符号隔开传入数据库,那拆分呢就是个大事 SELECT nPushID INTO #temp FROM Table1 ), nCoulmn) SELECT * FROM ...

  9. 忘记linux用户名和密码怎么解决?

    开机进入单用户模式,可跳过密码验证修改root密码. 具体步骤如下: 开机读秒时键盘上按回车 通过操纵键盘上下方向键选择系统版本,然后按下E 通过操纵键盘上下方向键选择kernel所在行,再次按下E进 ...

  10. caffe编译出现的新错误

    1.include/caffe/blob.hpp:9:34: fatal error: caffe/proto/caffe.pb.h: No such file or directory #inclu ...