Milk

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

 

Description

Ignatius drinks milk everyday, now he is in the 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. 

 

Input

The input contains several test cases. The first line 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. 
 

Output

For each test case, you should output the brand of the milk which is the cheapest. If there are more than one cheapest brand, you should output the one which has the largest volume. 
 

Sample Input

2
2
Yili 10 500
Mengniu 20 1000
4
Yili 10 500
Mengniu 20 1000
Guangming 1 199
Yanpai 40 10000

Sample Output

Mengniu
Mengniu

Hint

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.
题意:这个人每天喝200ml,一次牛奶最多喝5天,求性价比最高的牛奶
 #include<bits/stdc++.h>
using namespace std;
struct Node {
string s;
int mol;
int ml;
double rate;
} aa[];
int main() {
int t;
cin>>t;
while(t--) {
int n;
cin>>n;
for(int i=; i<n; i++) {
cin>>aa[i].s>>aa[i].mol>>aa[i].ml;
if(aa[i].ml>=)
aa[i].rate=aa[i].mol/;
else if(aa[i].ml>=) {
int x=aa[i].ml/;
aa[i].rate=aa[i].mol/(double)(x*1.0);
} else
aa[i].rate=-;
}
double minn=0x1f1f1f1f;
int k;
for(int j=; j<n; j++) {
if(aa[j].rate!=-) {
if(aa[j].rate!=-) {
if(aa[j].rate<minn) {
minn=aa[j].rate;
k=j;
}
}
}
}
cout<<aa[k].s<<endl;
}
return ;
}
 

HDU1070Milk的更多相关文章

随机推荐

  1. PHP学习之路 (2)

    我们如果坚持用windows做PHP开发,就会错误不断,所以,无论如何都要学习Linux的使用和安装.说实话<鸟哥的linux私房菜>是一本非常不错的书,但是如果你想照着书上面一步一步安装 ...

  2. windows下文件名非法字符

    / \ : * ? " < > | / \如果用作文件名,会产生路径问题.因为绝对路径用 \ ; 相对路径用  / ;

  3. UVA 100 The 3*n+1 problem

      UVA 100 The 3*n+1 problem. 解题思路:对给定的边界m,n(m<n&&0<m,n<1 000 000);求X(m-1<X<n+ ...

  4. Go原子计数

    通过原子计数可以在多线程情况下,对同一个数值进行加减操作,一般用于状态同步. 先看代码: package main import "fmt" import "time&q ...

  5. maven学习手记 - 2

    学习目标 maven 的插件和目标: maven 的生命周期和阶段.   前言 在手记1中看到执行 mvn clean package 时,maven 自动执行了compile 和 test 操作. ...

  6. [转]Gridview中实现RadioButton单选效果

    HTML <asp:TemplateField ItemStyle-Width="22px"> <ItemTemplate> <asp:RadioBu ...

  7. [原创]一个纯css实现兼容各种主流移动pc浏览器的时间轴

    废话不多说 Demo 高度完全的自适应 中心思想是table 和第二列行高的50%的上下绝对定位竖线 第一次用codepen less完全不能用啊 连node png之类的都是关键词会被去掉... 马 ...

  8. Android编程: fragment组件、菜单和Intent组件

    学习内容:fragment组件.菜单和Intent组件 ====fragment组件====1.fragment是一种自我容纳,模块化的,嵌入在一个Activity里面的视图组件    可以在运行时动 ...

  9. 6.Inout双向端口信号处理方法

    Verilog中inout端口的使用方法 (本文中所有Verilog描述仅为展示inout端口的用法,实际描述则需要更丰富的功能描述) Inout端口的使用 在芯片中为了管脚复用,很多管脚都是双向的, ...

  10. Android实现地图服务

    Android实现地图服务 开发工具:Andorid Studio 1.3 运行环境:Android 4.4 KitKat 代码实现 这里使用的是百度地图,具体配置方法请看官方文档即可.(也可以参考我 ...