Before an Exam

Source: Internet
Author: User

Description

Peter is going to take the biology exam tomorrow. But he did not like the subject, but D days ago, Peter's strict parents asked him to prepare for the exam immediately, so, on the first day, he had to study not less than Mintimei time, and not more than Maxtimei time.    In addition, his parents warned Peter that the day before the exam, they would check whether he followed their instructions in the review. Today, Peter's parents came to check and asked him to show a daily review schedule. But Peter only remembers the total time spent sumtime, now in order to cope with parental examination, please help him to create a daily learning schedule, so as to meet the daily study time requirements, and the total time equals sumtime.

Input

The first line of input contains two integers d and sumtime (1≤d≤30,0≤sumtime≤240), respectively, representing the total number of days and total time of review. The following D line contains two integers mintimei and Maxtimei (0≤mintimei≤maxtimei≤8), separated by spaces, indicating the minimum and maximum time to review each day.

Output

If there is no solution, output No, if there is a solution, first row output Yes, and then the second line output the time of day learning, the middle of a space separated (output any one solution can).

Sample Input

Input example 1:1 485 7 input Sample 2:2 50 13 5

Sample Output

Output sample 1:no Output Example 2:yes1 4
#include <iostream> #include <cstdio> #include <cstring>using namespace std;struct da{int mintime, max    Time int max_min;}    As[1000];int ans[1000];///Analog int main () {int n, I, OK, sumtime, left, right, K, id;       while (~SCANF ("%d%d", &n, &sumtime)) {memset (ans, 0, sizeof (ans)); K = OK = 0;       left = right = 0;           for (i = 1; I <= n; i++) {scanf ("%d%d", &as[i].mintime, &as[i].maxtime);           As[i].max_min = As[i].maxtime-as[i].mintime;           Left + = As[i].mintime;           Right + = As[i].maxtime;       Ans[i] = As[i].mintime;       } if (Sumtime >= left && sumtime <= right) ok = 1;           if (ok) {k = sumtime-left; id = 1;                     while (k) {if (k >= as[id].max_min) {Ans[id] + = as[id].max_min;               K-= as[id].max_min; } else {ans[id] + = k;               k = 0;           } id++;           } printf ("yes\n");           printf ("%d", ans[1]);           for (i = 2; I <= n; i++) printf ("%d", ans[i]);       printf ("\ n");    } else printf ("no\n"); } return 0;}

  

Before an Exam

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.