日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Codeforces Beta Round #4 (Div. 2 Only) B. Before an Exam dp

發布時間:2023/12/10 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Codeforces Beta Round #4 (Div. 2 Only) B. Before an Exam dp 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

B. Before an Exam

題目連接:

http://www.codeforces.com/contest/4/problem/B

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 d numbers, 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 numbers minTimei,?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

1 48
5 7

Sample Output

NO

Hint

題意

有n天,你一共學習了m個小時。

這n天每天你必須學習li個小時,但是不能超過ri小時。

問你m個小時能不能合理分配,滿足這n天的要求。

如果可以,輸出方案。

題解:

直接dp就好了,dp[i][j]表示到了第i天,一共學習了j個小時。

然后記錄一下從哪兒轉移過來的就好了。

不過數據范圍好小,估計怎么做都可以……

代碼

#include<bits/stdc++.h> using namespace std; const int maxn = 35; int n,m; int l[maxn],r[maxn]; int dp[35][1200],from[35][1200]; void solve(int x,int y) {if(x!=1)solve(x-1,from[x][y]);printf("%d ",y-from[x][y]); } int main() {scanf("%d%d",&n,&m);for(int i=1;i<=n;i++)scanf("%d%d",&l[i],&r[i]);dp[0][0]=1;for(int i=1;i<=n;i++){for(int j=0;j<1000;j++){if(dp[i-1][j]){for(int k=l[i];k<=r[i];k++){dp[i][j+k]=1;from[i][j+k]=j;}}}}if(dp[n][m]){cout<<"YES"<<endl;solve(n,m);}else cout<<"NO"<<endl; }

轉載于:https://www.cnblogs.com/qscqesze/p/5293318.html

總結

以上是生活随笔為你收集整理的Codeforces Beta Round #4 (Div. 2 Only) B. Before an Exam dp的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 激情视频一区二区 | 色久在线 | 好吊色一区二区 | 51自拍视频 | 日日摸夜夜添狠狠添欧美 | 亚洲免费精品视频在线观看 | 亚洲免费精品视频在线观看 | 亚洲精品久久一区二区三区777 | xxav在线 | 福利视频免费观看 | 久热中文字幕在线 | 91欧美一区二区三区 | 四月婷婷| 亚洲成人动漫在线观看 | 青青草97| 久久久久久久久精 | 一本久久久 | 国产精品成人在线观看 | 久久久久久国产精品一区 | www.av欧美 | 99re久久精品国产 | 91午夜精品 | 美女搞黄在线观看 | 成人在线观看免费高清 | 四虎影院永久 | 和美女啪啪| 亚洲高清在线 | 欧美毛片网站 | 幸福宝在线观看 | 国产操女人 | 国产第一页视频 | 亚洲av片不卡无码久久 | va在线视频 | 九九精品网 | 亚洲AV午夜精品 | 成人免费黄 | 极品国产91在线网站 | 日本在线观看视频网站 | 熟女人妇 成熟妇女系列视频 | 黄色片a级 | 国产特级淫片免费看 | 精品久久久久久久久久 | 中文字幕在线播放 | 中文字幕免费观看 | 色婷婷一区二区 | 91成人免费在线视频 | 午夜影院久久 | 麻豆视频网站入口 | 刘亦菲久久免费一区二区 | 污污内射在线观看一区二区少妇 | 一区二区视频免费 | 成人手机视频 | 欧美又粗又大xxxxbbbb疯狂 | 91久久精品视频 | 成人免费毛片嘿嘿连载 | 亚洲第1页 | 久久亚洲在线 | 干丰满少妇| 日本免费专区 | 丁香久久综合 | 亚洲干 | 性按摩玩人妻hd中文字幕 | 国产精品自拍片 | 久久久久婷婷 | 五月婷婷六月香 | 奇米影视一区二区 | 99久久婷婷国产综合精品电影 | 亚洲手机在线观看 | 欧美第一页草草影院 | 日韩在线观看网址 | 男人操女人免费视频 | 真实的中国女人做爰 | 欧美三区 | 国产精品无码成人网站视频 | 午夜激情视频网 | 亚洲综合色自拍一区 | 无限资源日本好片 | 国产激情久久久久久熟女老人av | 亚洲精品 欧美 | 亚洲黄色大片 | 白嫩白嫩国产精品 | 欧美激情一区二区 | 久久不卡 | 日本大尺度做爰呻吟 | 国产视频在线观看视频 | 色鬼久久| 青草青在线 | 丝袜国产一区 | 18被视频免费观看视频 | 一区二区三区免费看 | www.jizzjizz | 欧美伦理一区二区 | jizz亚洲女人 | 香蕉网久久 | avtt国产| 国产3区| 欧美精品自拍 | 国产精品视频专区 | 国产欧美一区二区三区在线看蜜臀 |