hdu 1070 Milk(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1070
Milk
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 14286 Accepted Submission(s):
3525
supermarket and he wants to choose a bottle of milk. There are many kinds of
milk in the supermarket, so Ignatius wants to know which kind of milk is the
cheapest.
Here are some rules:
1. Ignatius will never drink the milk
which is produced 6 days ago or earlier. That means if the milk is produced
2005-1-1, Ignatius will never drink this bottle after 2005-1-6(inclusive).
2.
Ignatius drinks 200mL milk everyday.
3. If the milk left in the bottle is
less than 200mL, Ignatius will throw it away.
4. All the milk in the
supermarket is just produced today.
Note that Ignatius only wants to buy
one bottle of milk, so if the volumn of a bottle is smaller than 200mL, you
should ignore it.
Given some information of milk, your task is to tell
Ignatius which milk is the cheapest.
of the input is a single integer T which is the number of test cases. T test
cases follow.
Each test case starts with a single integer N(1<=N<=100)
which is the number of kinds of milk. Then N lines follow, each line contains a
string S(the length will at most 100 characters) which indicate the brand of
milk, then two integers for the brand: P(Yuan) which is the price of a bottle,
V(mL) which is the volume of a bottle.
milk which is the cheapest. If there are more than one cheapest brand, you
should output the one which has the largest volume.
In the first case, milk Yili can be drunk for 2 days, it costs 10 Yuan. Milk Mengniu can be drunk for 5 days, it costs 20 Yuan. So Mengniu is the cheapest.In the second case,
milk Guangming should be ignored. Milk Yanpai can be drunk for 5 days, but it costs 40 Yuan. So Mengniu is the cheapest.
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std; int main()
{
char name[],min_name[];
double Min,s;
int min_v;
int T,p,v,d,n;
scanf("%d",&T);
while (T--)
{
Min=;
min_v=;
scanf("%d",&n);
while(n--)
{
scanf("%s%d%d",name,&p,&v);
if (v<)
continue;
if (v/>=)
s=p/;
else
s=p*1.0/(v/);
if(Min>s)
{
min_v=v;
Min=s;
strcpy(min_name,name);
}
else if(Min==s)
{
if(min_v<v)
{
min_v=v;
strcpy(min_name,name);
}
}
}
printf("%s\n",min_name);
}
return ;
}
hdu 1070 Milk(贪心)的更多相关文章
- HDU 1070 Milk (模拟)
题目链接 Problem Description Ignatius drinks milk everyday, now he is in the supermarket and he wants to ...
- HDU 1070 - Milk
给每种牛奶价格和量 要求买最便宜的牛奶 #include <iostream> using namespace std; int t,n; ][]; ],v[]; int main() { ...
- Hdu 4864(Task 贪心)(Java实现)
Hdu 4864(Task 贪心) 原题链接 题意:给定n台机器和m个任务,任务和机器都有工作时间值和工作等级值,一个机器只能执行一个任务,且执行任务的条件位机器的两个值都大于等于任务的值,每完成一个 ...
- D - 淡黄的长裙 HDU - 4221(贪心)
D - 淡黄的长裙 HDU - 4221(贪心) James is almost mad! Currently, he was assigned a lot of works to do, so ma ...
- HDOJ.1070 Milk(贪心)
Milk 点我挑战题目 题意分析 每组测试数据给出一系列牛奶商品,分别是牛奶的品牌,价格,以及体积.在读取数据的时候,体积在200以下的牛奶直接忽略掉.并且每天要喝200ML的牛奶.但是无论牛奶体积有 ...
- hdu 2037简单贪心--活动安排问题
活动安排问题就是要在所给的活动集合中选出最大的相容活动子集合,是可以用贪心算法有效求解的很好例子.该问题要求高效地安排一系列争用某一公共资源的活动.贪心算法提供了一个简单.漂亮的方法使得尽可能多的活动 ...
- HDU 4864 Task (贪心+STL多集(二分)+邻接表存储)(杭电多校训练赛第一场1004)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4864 解题报告:有n台机器用来完成m个任务,每个任务有一个难度值和一个需要完成的时间,每台机器有一个可 ...
- HDU 4310 Hero (贪心算法)
A - Hero Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Sta ...
- hdu 4268 multiset+贪心
Alice和Bob有n个长方形,有长度和宽度,一个矩形可以覆盖另一个矩形的条件的是,本身长度大于等于另一个矩形,且宽度大于等于另一个矩形,矩形不可旋转,问你Alice最多能覆盖Bob的几个矩形? /* ...
随机推荐
- 《Effective C#》快速笔记(三)- 使用 C# 表达设计
目录 二十一.限制类型的可见性 二十二.通过定义并实现接口替代继承 二十三.理解接口方法和虚方法的区别 二十四.用委托实现回调 二十五.用事件模式实现通知 二十六.避免返回对内部类对象的引用 二十七. ...
- C# Parsing 类实现的 PDF 文件分析器
下载示例 下载源代码 1. 介绍 这个项目让你可以去读取并解析一个PDF文件,并将其内部结构展示出来. PDF文件的格式标准文档可以从Adobe那儿获取到. 这个项目基于“PDF指南,第六版,Adob ...
- 织梦CMS建站入门学习(二)
织梦建站的数据库设计: 1.模型表:根据网站的需求,建立不同的数据模型,如:文章浏览,软件下载,视频观看等等. 2.栏目表:根据网站的需求,建立不同的栏目,每一个栏目选择一个数据模型. 3.内容主表: ...
- Android------去除标题栏
这里暂时只给出一种方法,在java代码中去除 1.继承Activity 在onCreate方法中 getWindow().setFlags(WindowManager.LayoutParams.FLA ...
- [计算机网络] 互联网协议栈(TCP/IP参考模型)各层的主要功能及相应协议
应用层:提供用户与网络间的接口.----HTTP.FTP.SMTP 运输层:进程到进程间的数据传输.---TCP.UDP 网络层:主机到主机之间的数据传输.---IP.选路协议 数据链路层:相邻结点之 ...
- MVC绕过登陆界面验证时HttpContext.Current.User.Identity.Name取值为空问题解决方法
Global.asax界面添加如下方法: void FormsAuthentication_Authenticate(object sender, FormsAuthenticationEventAr ...
- 【bzoj1692】[Usaco2007 Dec]队列变换 贪心+后缀数组
题目描述 FJ打算带他的N(1 <= N <= 30,000)头奶牛去参加一年一度的“全美农场主大奖赛”.在这场比赛中,每个参赛者都必须让他的奶牛排成一列,然后领她们从裁判席前依次走过. ...
- python函数入门到高级
函数的定义: def test(x): "The function definitions" x+=1 return x def:定义函数的关键字 test:函数名 ():内可定义 ...
- [洛谷P3627][APIO2009]抢掠计划
题目大意:给你一张$n(n\leqslant5\times10^5)$个点$m(m\leqslant5\times10^5)$条边的有向图,有点权,给你起点和一些可能的终点.问从起点开始,到任意一个终 ...
- [洛谷P4735]最大异或和
题目大意:有一串初始长度为$n$的序列$a$,有两种操作: $A\;x:$在序列末尾加一个数$x$ $Q\;l\;r\;x:$找一个位置$p$,满足$l\leqslant p\leqslant r$, ...