Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 20   Accepted Submission(s) : 12

Font: Times New Roman | Verdana | Georgia

Font Size: ← →

Problem 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.
#include<iostream>
#include<string>
using namespace std;
struct node
{
string na;
int p,v;
double w;
}a[1005];
int main()
{
int t,n;
cin>>t;
while(t--)
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].na>>a[i].p>>a[i].v;
if(a[i].v>=1200)
a[i].w=a[i].p/5;
else if(a[i].v>=200)
{
int x=a[i].v/200;
a[i].w=a[i].p/double(x*1.0);
}
else a[i].w=-1;
}
double minx=0x7777777;
int k;
for(int j=1;j<=n;j++)
{
if(a[j].w!=-1)
{
if(a[j].w<minx)
{
minx=a[j].w;
k=j;
}
}
}
cout<<a[k].na<<endl;
}
return 0;
}

  

Milk的更多相关文章

  1. BZOJ 1717: [Usaco2006 Dec]Milk Patterns 产奶的模式 [后缀数组]

    1717: [Usaco2006 Dec]Milk Patterns 产奶的模式 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 1017  Solved: ...

  2. POJ 3261 Milk Patterns 后缀数组求 一个串种 最长可重复子串重复至少k次

    Milk Patterns   Description Farmer John has noticed that the quality of milk given by his cows varie ...

  3. 【BZOJ-1717】Milk Patterns产奶的模式 后缀数组

    1717: [Usaco2006 Dec]Milk Patterns 产奶的模式 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 881  Solved:  ...

  4. 后缀数组---Milk Patterns

    POJ  3261 Description Farmer John has noticed that the quality of milk given by his cows varies from ...

  5. POJ 3261 Milk Patterns (求可重叠的k次最长重复子串)+后缀数组模板

    Milk Patterns Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 7586   Accepted: 3448 Cas ...

  6. 洛谷P1215 [USACO1.4]母亲的牛奶 Mother's Milk

    P1215 [USACO1.4]母亲的牛奶 Mother's Milk 217通过 348提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交  讨论  题解 最新讨论 暂时没有讨论 ...

  7. 【BZOJ】【1717】【USACO 2006 Dec】Milk Patterns产奶的模式

    后缀数组 o(︶︿︶)o 唉傻逼了一下,忘了把后缀数组的字典范围改回20001,直接21交了上去,白白RE了两发……sigh 既然要找出现了K次的子串嘛,那当然要用后缀数组了>_>(因为我 ...

  8. HDU1070 Milk 细节决定成败

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1070 注意:1.喝到第五天,第六天就不喝了  2.相同花费的,优先考虑容量大的  3.注意强制类型转换 ...

  9. bzoj1717: [Usaco2006 Dec]Milk Patterns 产奶的模式

    后缀数组+二分答案+离散化.(上次写的时候看数据小没离散化然后一直WA...写了lsj师兄的写法. #include<cstdio> #include<cstring> #in ...

随机推荐

  1. 获取txt文件指定行内容

    #!/usr/bin/python num=0; ni=open("C:\Python34\ceshi.txt") for line in ni: num=num+1;  #表示行 ...

  2. SO修改

    FUNCTION Z_SD_SALESORDER_CHANGE1. *"----------------------------------------------------------- ...

  3. Objective-C:Foundation框架-常用类-NSString全解

    Foundation框架中常用的类有字符串.集合.字典等,这里介绍字符串NSString.本文分别介绍了NSString的创建.从文件里读取NSString字符串.通过函数改变外部的NSString变 ...

  4. biztalk中使用WCF-SQL接受传送数据【转】

    接触biztalk时间不长,转载一篇学习教程: http://www.cnblogs.com/chnking/archive/2010/05/09/1731098.html chnking写的. 一. ...

  5. tomcat 下虚拟机部署导致应用filter失效的问题

    遇到一个困扰我两天的问题 服务器的tomcat上面挂了3个项目 1个项目在D:\tomcat\\webapps\ROOT下  运行正常 1个项目在D:\heyefan下 运行正常 1个项目在D:\MA ...

  6. gitlab配置邮件通知

    配置用户提交评论.添加issue等的邮件通知: Gitlab邮件提醒方便跟踪项目进度,在这里介绍两种方式,一种是用系统的sendmail发送邮件,另一种是GMAIL的stmp来发送邮件 第一种 用系统 ...

  7. 在Web中如何使用Windows控件(ActiveX)[转]

    最近做的一个Web项目,需要在网页中播放摄像头采集的实时视频,我们已经有了播放视频的使用C#编写的windows控件,如何将其嵌入到网页中去了?这需要使用一种古老的技术,ActiveX. 1.将.Ne ...

  8. 如何在Quagga BGP路由器中设置IPv6的BGP对等体和过滤

    在本教程中,我们会向你演示如何创建IPv6 BGP对等体并通过BGP通告IPv6前缀.同时我们也将演示如何使用前缀列表和路由映射特性来过滤通告的或者获取到的IPv6前缀. 拓扑 服务供应商A和B希望在 ...

  9. dedecms二级菜单实现

    修改channelartlist.lib.php if($typeid==0 || $typeid=='top') { $tpsql = " reid=0 AND ispart<> ...

  10. 纯JS省市区三级联动

    代码下载