uva10465Homer Simposon(完全背包)
发布日期:2022-02-02 02:58:10
浏览次数:24
分类:技术文章
本文共 1462 字,大约阅读时间需要 4 分钟。
Problem C: | Homer Simpson |
Time Limit: 3 seconds Memory Limit: 32 MB |
Homer Simpson, a very smart guy, likes eating Krusty-burgers. It takes Homer m minutes to eat a Krusty- burger. However, there�s a new type of burger in Apu�s Kwik-e-Mart. Homer likes those too. It takes him n minutes to eat one of these burgers. Given t minutes, you have to find out the maximum number of burgers Homer can eat without wasting any time. If he must waste time, he can have beer. |
Input
Input consists of several test cases. Each test case consists of three integers m, n, t (0 < m,n,t < 10000). Input is terminated by EOF.
Output
For each test case, print in a single line the maximum number of burgers Homer can eat without having beer. If homer must have beer, then also print the time he gets for drinking, separated by a single space. It is preferable that Homer drinks as little beer as possible.
Sample Input
3 5 543 5 55
Sample Output
1817
Problem setter: Sadrul Habib Chowdhury Solution author: Monirul Hasan (Tomal)
Time goes, you say? Ah no! Alas, Time stays, we go. -- Austin Dobson
#include#include using namespace std;int dp[10001];int w[3];int sum[10001];int main(){ int m,n,t,i,j; while(cin>>m>>n>>t) { w[1]=m;w[2]=n; memset(dp,0,sizeof(dp)); memset(sum,0,sizeof(sum)); for(i=1;i<=2;i++) { for(j=0;j<=t;j++) { if(j>=w[i]) { if(dp[j]
转载地址:https://blog.csdn.net/u010368749/article/details/19828543 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
第一次来,支持一个
[***.219.124.196]2024年04月09日 15时46分26秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
【力扣】168. Excel表列名称
2019-04-26
【力扣】456. 132 模式
2019-04-26
【力扣】82. 删除排序链表中的重复元素 II
2019-04-26
【剑指OFFER】 41. 数据流中的中位数
2019-04-26
【力扣】83. 删除排序链表中的重复元素
2019-04-26
【剑指OFFER】 43. 1~n 整数中 1 出现的次数
2019-04-26
【剑指OFFER】44. 数字序列中某一位的数字
2019-04-26
【剑指OFFER】45. 把数组排成最小的数
2019-04-26
【区块链】使用JAV简易A模拟创建区块链及挖矿
2019-04-26
【力扣】74. 搜索二维矩阵
2019-04-26
【剑指OFFER】46. 把数字翻译成字符串
2019-04-26
【剑指OFFER】47. 礼物的最大价值
2019-04-26
【力扣】90. 子集 II
2019-04-26
【剑指OFFER】48. 最长不含重复字符的子字符串
2019-04-26
【力扣】80. 删除有序数组中的重复项 II
2019-04-26
【剑指OFFER】50. 第一个只出现一次的字符
2019-04-26
【剑指OFFER】57 - II. 和为s的连续正数序列
2019-04-26
【Java】 用PriorityQueue实现最大最小堆
2019-04-26
【剑指OFFER】49. 丑数
2019-04-26
【力扣】179. 最大数
2019-04-26