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. recurse_array_change_key_case()递规返回字符串键名全为小写或大写的数组

    //递归返回字符串键名全为小写或大写的数组function recurse_array_change_key_case(&$input, $case = CASE_LOWER){    if( ...

  2. Laravel 5 基础(九)- 表单

    首先让我们修改路由,能够增加一个文章的发布. Route::get('articles/create', 'ArticlesController@create'); 然后修改控制器 public fu ...

  3. Java 装箱 拆箱

    Java 自动装箱与拆箱   ??什么是自动装箱拆箱 基本数据类型的自动装箱(autoboxing).拆箱(unboxing)是自J2SE 5.0开始提供的功能. 一般我们要创建一个类的对象的时候,我 ...

  4. 关于frameset中指定区域回退的实现

    指定区域(Frame)的回退,网上大都写的是用  window.parent.window.mainFrame.rightFrame.history.back();来进行回退,但是我这边就是不行,一直 ...

  5. MVC中的奇葩错误,参数转对象

    在使用MVC中遇到一个神奇的错误,特此记录(我在用MVC4时遇到) 上面两张图就是一个变量名进行了修改,其他不变!form里面的参数也是一样的!喜欢尝试的可以尝试一下! 我的变量使用action时出现 ...

  6. Multi-Language IDE for Professional Developers (Komodo)

    Komodo is the professional IDE for major web languages, including Python, PHP, Ruby, Perl, HTML, CSS ...

  7. 《大话设计模式》ruby版代码:策略模式

    需求: 商场收银软件,根据客户购买物品的单价和数量,计算费用,会有促销活动,打八折,满三百减一百之类的. 一,使用工厂模式. # -*- encoding: utf-8 -*- #现金收费抽象类 cl ...

  8. Win8.1想要卸载openSUSE出现问题(2014.8.15已解决)

    用DiskGenius激活C盘后果然好用了!随便用EasyBCD恢复一下就好了 下面再说说安装openSUSE这半周多的问题: 1.如果是NVIDIA和Intel双显卡就不要安装NVIDIA的显卡驱动 ...

  9. [笔记]--Python字符串处理

    一.截取字符串中的内容 1.截取: MsiExec.exe /I{AC76BA86-7AD7-2052-7B44-AB0000000001} 中的: {AC76BA86-7AD7-2052-7B44- ...

  10. wpf mvvm MenuItem的Command事件

    这是一个事件的辅助类,可以通过它实现MenuItem的Command事件 public class MyCommands : Freezable, ICommand, ICommandSource { ...