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<cstdio>
#include<algorithm>
using namespace std;
struct nam
{
int v;
float y;
char a[];
} milk[];
bool f(nam a,nam b)
{
double ka,kb;
int da,db;
da=(a.v/)>?:(a.v/);
db=(b.v/)>?:(b.v/);
ka=a.y*1.0/da;
kb=b.y*1.0/db;
if(ka!=kb) return ka<kb;
else
return a.v>b.v; }
int main()
{
int t,n;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=;i<n;i++)
{
scanf("%s %f %d",&milk[i].a,&milk[i].y,&milk[i].v);
if(milk[i].v<)
{
i--;
n--;
} }
sort(milk,milk+n,f);
printf("%s\n",milk[].a); }
}

Milk(sort+结构体)的更多相关文章

  1. sort+结构体实现二级排序

    之前介绍的sort函数由于其效率较高,使用较为简单让我用起来那叫一个爽,今天再写一篇使用sort+结构体实现二级排序的方法. 还是先想个问题吧,比如我想输入5个同学的名字和身高,然后得到他们身高的降序 ...

  2. 网上关于sort结构体排序都不完整,我来写一个完整版的 2014-08-09 16:50 60人阅读 评论(0) 收藏

    主要参考sort函数_百度文库, 但是那篇有错误 2.结构体排序,a升,b降,c降 平板视图 打印? 01 #include <iostream> 02 #include <algo ...

  3. A - 开门人和关门人(sort+结构体)

    点击打开链接 每天第一个到机房的人要把门打开,最后一个离开的人要把门关好.现有一堆杂乱的机房签  到.签离记录,请根据记录找出当天开门和关门的人.  Input 测试输入的第一行给出记录的总天数N ( ...

  4. 洛谷P1068 分数线划定:sort结构体排序+贪心

    题目描述 世博会志愿者的选拔工作正在 A 市如火如荼的进行.为了选拔最合适的人才,A市对所有报名的选手进行了笔试,笔试分数达到面试分数线的选手方可进入面试. 面试分数线根据计划录取人数的150%划定, ...

  5. B - EXCEL排序(sort+结构体)

    Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. Input测试输入包含若干测试用例.每个测试用例的第1行包含两个整数 N (<=100000) 和 C,其中 N 是纪录的 ...

  6. sort 结构体 正数负数分开排序

    对于结构体排序的一点点记录,之前遇到过结构体排序,个人比较喜欢使用在结构体当中直接重载小于号的方法, 例如说: struct Node{ int index; int del; bool operat ...

  7. sort+结构体+简单数学+暴力-例题

    A-前m大的数 还记得Gardon给小希布置的那个作业么?(上次比赛的1005)其实小希已经找回了原来的那张数表,现在她想确认一下她的答案是否正确,但是整个的答案是很庞大的表,小希只想让你把答案中最大 ...

  8. UVA 10881 Piotr's Ants(等效变换 sort结构体排序)

    Piotr's AntsTime Limit: 2 seconds Piotr likes playing with ants. He has n of them on a horizontal po ...

  9. 稳定排序(sort+结构体)

    #include<cstdio> #include<algorithm> #include<string.h> using namespace std; struc ...

随机推荐

  1. gvim 常用键

    按i 切换到插入模式,ESC退出 命令模式下 dd 删除一行 dw 删除一个字 x 删除一个字符 :set num  设置行号 :reg 查看寄存器 p 粘贴 y 复制 "*p  不同环境下 ...

  2. JSP | 基础 | 加载类失败:com.mysql.jdbc.Driver

    两个原因: 1. 连接数据库需要的jar包没有导入Tomcat的lib库中 解决方案: 打开Tomcat的安装目录下的lib文件夹,把jar包拖进lib库后,重启tomcat服务器 2.  mysql ...

  3. mysql-SQL语法

    细节查询:http://www.w3school.com.cn/sql/index.asp 1 DDL-data difinition lanuage数据定义语句 使我们有能力创建或删除表格,我们也可 ...

  4. php.ini配置文件位置

    laravel之今天遇到个意想不到的问题: 我在测试文件上传,大于2M的文件时候hasFile() 方法报错,这一定是文件大小限制.接下来就跳坑了 1.首先查找php.ini的位置,就用find / ...

  5. Mice and Holes CodeForces - 797F

    Mice and Holes CodeForces - 797F 题意:有n只老鼠和m个洞,都在一个数轴上,老鼠坐标为x[1],...,x[n],洞的坐标为p[1],...,p[m],每个洞能容纳的老 ...

  6. 组合数+容斥原理 UVALive 7040 Color(14西安F)

    题目传送门 题意:n盆花涂色,相邻不能涂相同的颜色,从m中颜色选取k种颜色涂,保证正好有k种颜色 分析:从m中颜色选取k种就是C (m, k),然后第一个有k种选择,之后的都有k-1种选择,这样是不超 ...

  7. 481 Magical String 魔力字符串

    详见:https://leetcode.com/problems/magical-string/description/ C++: 方法一: class Solution { public: int ...

  8. 127 Word Ladder 单词接龙

    给出两个单词(beginWord 和 endWord)和一个字典,找到从 beginWord 到 endWord 的最短转换序列,转换需遵循如下规则:    每次只能改变一个字母.    变换过程中的 ...

  9. subline应用之技巧

    看很多人代码编辑器都用subline,一了解这货也跨平台.支持代码提示自动补全.支持python.语法高亮.最关键的是支持列编辑(原来以为只有ue有此功能),那就果断下载使用,挺好! 列编辑:首先用鼠 ...

  10. Unity基础知识

    hierarchy视图选中,点击scene视图,按f键聚焦 persp相当于是透视视野 在persp模式下,物体在scene界面上所呈现的画面是给人一种距离摄像头近的物体显示的大,距离摄像头远的物体显 ...