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的几个矩形? /* ...
随机推荐
- mysql8基本配置,差点被各种坑蒙圈
1. 下载免安装版mysql地址 https://dev.mysql.com/downloads/mysql/ 2. 基本配置 (1)解压zip包,将bin目录添加到环境变量 (2)在mysql根目录 ...
- phpcms添加自定义字段
设置 :后台 --- 内容 ---- 模型管理 ---- 对应的模型 --- 字段管理 新增加自定义字段:phpcms123 调用新增字段代码: {pc:content action=&qu ...
- BZOJ3709 [PA2014]Bohater 【贪心】
题目链接 BZOJ3709 题解 贪心很显然 我们先干掉能回血的怪,当然按照\(d\)升序顺序,因为打得越多血越多,\(d\)大的尽量往后打 然后再干掉会扣血的怪,当然按照\(a\)降序顺序,因为最后 ...
- Hadoop Yarn-入门篇
参考并推荐博文:https://www.ibm.com/developerworks/cn/opensource/os-cn-hadoop-yarn/ 重构根本的思想是将 JobTracker 两个主 ...
- BZOJ2791 Rendezvous
Description给定一个n个顶点的有向图,每个顶点有且仅有一条出边.对于顶点i,记它的出边为(i, a[i]).再给出q组询问,每组询问由两个顶点a.b组成,要求输出满足下面条件的x.y:1. ...
- 【简单算法】18.实现strStr()
题目: 实现 strStr() 函数. 给定一个 haystack 字符串和一个 needle 字符串,在 haystack 字符串中找出 needle 字符串出现的第一个位置 (从0开始).如果不存 ...
- Codeforces Round #508 (Div. 2) D. Slime
D. Slime 题目链接:https://codeforces.com/contest/1038/problem/D 题意: 给出两个数,然后每次可以对相邻的两个数合并,比如x,y,那么合并过后就是 ...
- im-switch -s ibus错误:Error: no configuration file "ibus" exists.
在虚拟机上安装Ubuntu14.04 后安装ibus输入法,万万没想到在切换输入法的时候居然出错了! 无语了,再网上查了一下,这个错误出现的还是比较少的. 先说Ubuntu输入法(ibus)安装的一般 ...
- NYOJ 745 dp
蚂蚁的难题(二) 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 下雨了,下雨了,蚂蚁搬家了. 已知有n种食材需要搬走,这些食材从1到n依次排成了一个圈.小蚂蚁对每种 ...
- Mac 访问隐藏文件方法! 网上方法在我电脑上都不可用!
百度的方法: 如果你想打开整个系统的隐藏文件可以在终端下输入以下命令 defaults write com.apple.finder AppleShowAllFiles -bool true 关闭显示 ...