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. gRPC Client的负载均衡器

    一.gRPC是什么? gRPC是一个高性能.通用的开源RPC框架,其由Google主要面向移动应用开发并基于HTTP/2协议标准而设计,基于ProtoBuf(Protocol Buffers)序列化协 ...

  2. STM32F4_USART配置及细节描述

    Ⅰ.概述 关于USART串口通信,可以说是MCU的标配.不管是在实际项目应用中,还是在开发过程中,它都起着很重要的作用. 在项目应用中我们常常使用UART串口进行通信,根据通信的距离及稳定性,还选择添 ...

  3. pure的bug记录2

    <select id="stacked-state" style=" font-family: "Microsoft YaHei"; " ...

  4. 理解ruby on rails中的ActiveRecord::Relation

    ActiveRecord::Relation是rails3中添加的.rails2中的finders, named_scope, with_scope 等用法,在rails3统一为一种Relation用 ...

  5. java遍历Map的几种方式

    1.遍历map的几种方式:private Hashtable<String, String> emails = new Hashtable<String, String>(); ...

  6. CentOS6.4上搭建hadoop-2.4.0集群

    公司Commerce Cloud平台上提供申请主机的服务.昨天试了下,申请了3台机器,搭了个hadoop环境.以下是机器的一些配置: emi-centos-6.4-x86_64medium | 6GB ...

  7. 通过Roslyn构建自己的C#脚本

    通过Roslyn构建自己的C#脚本 在下一代的C#中,一个重要的特性就是"Compiler as a Service",简单的讲,就是就是将编译器开放为一种可在代码中调用的服务.最 ...

  8. 微价值:专访《甜心爱消除》的个人开发者Lee,日入千元

    [导语] 我们希望能够对一些个人开发者进行专访,这样大家更能显得接地气,看看人家做什么,怎么坚持.<甜心爱消除>作者Lee是三群的兄弟,也关注微价值.微价 值的文章还是可以的,得到一些业内 ...

  9. MVC4.0 使用Form认证,自定义登录页面路径Account/Login

    使用MVC4.0的时候,一般遇到会员登录.注册功能,我们都会使用Form认证,给需要身份验证的Action进行授权(需要登录后才能访问的Action添加[Authorize]属性标签),登录.注册的时 ...

  10. ActiveX控件的基本操作方法以及如何在VS2010下使用控件

    在此,小编就介绍下ActiveX控件的基本操作方法以及如何在VS2010下使用控件,我们以一个程序为例, (1)      打开VS2010编译器(右键以管理员身份运行,因为ActiveX需要注册), ...