题目链接

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 HintIn 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<stdio.h>
#include<cstdlib>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;
struct Niunai
{
char str[103];
double a;///价钱
double b;///体积
double c;///单价
} aa[104];
bool camp(Niunai x,Niunai y)
{
if(x.c!=y.c)///单价按照从小到大排序
return (x.c<y.c);
else
return (x.b>y.b);///单价相同,按照体积从大到小排序
}
int main()
{
int n;
scanf("%d",&n);
while(n--)
{
memset(aa,0,sizeof(aa));///每次进行完,数组要刷新,
int m;
double n1;
scanf("%d",&m);
for(int i=0; i<m; i++)
{
scanf("%s%lf%lf",aa[i].str,&aa[i].a,&aa[i].b);
if(aa[i].b<200)
aa[i].c=0x3f3f3f;
else
{
n1=(int)(aa[i].b/200);
if(n1>=5)
n1=5;
aa[i].c=(double)(aa[i].a/n1);///得到每天的价钱
}
}
sort(aa,aa+m,camp);
printf("%s\n",aa[0].str);
}
return 0;
}

HDU 1070 Milk (模拟)的更多相关文章

  1. hdu 1070 Milk(贪心)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1070 Milk Time Limit: 2000/1000 MS (Java/Others)    M ...

  2. HDU 1070 - Milk

    给每种牛奶价格和量 要求买最便宜的牛奶 #include <iostream> using namespace std; int t,n; ][]; ],v[]; int main() { ...

  3. HDU 4121 Xiangqi 模拟题

    Xiangqi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4121 ...

  4. hdu 5071 Chat(模拟)

    题目链接:hdu 5071 Chat 题目大意:模拟题. .. 注意最后说bye的时候仅仅要和讲过话的妹子说再见. 解题思路:用一个map记录每一个等级的妹子讲过多少话以及是否有这个等级的妹子.数组A ...

  5. hdu 4740【模拟+深搜】.cpp

    题意: 给出老虎的起始点.方向和驴的起始点.方向.. 规定老虎和驴都不会走自己走过的方格,并且当没路走的时候,驴会右转,老虎会左转.. 当转了一次还没路走就会停下来.. 问他们有没有可能在某一格相遇. ...

  6. HDU 2568[前进]模拟

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2568 关键思想:傻傻地模拟 代码如下: #include<iostream> using ...

  7. hdu 4964 恶心模拟

    http://acm.hdu.edu.cn/showproblem.php?pid=4964 给定语句,按照语法翻译html并输出. 就是恶心的模拟,递归搞就行了 处理id和class时,在一个'&g ...

  8. HDOJ.1070 Milk(贪心)

    Milk 点我挑战题目 题意分析 每组测试数据给出一系列牛奶商品,分别是牛奶的品牌,价格,以及体积.在读取数据的时候,体积在200以下的牛奶直接忽略掉.并且每天要喝200ML的牛奶.但是无论牛奶体积有 ...

  9. HDU 5965 枚举模拟 + dp(?)

    ccpc合肥站的重现...一看就觉得是dp 然后强行搞出来一个转移方程 即 根据第i-1列的需求和i-1 i-2列的枚举摆放 可以得出i列摆放的种类..加了n多if语句...最后感觉怎么都能过了..然 ...

随机推荐

  1. iOS-开发过程中应用间跳转问题

  2. cURL和file_get_contents实现模拟post请求

    以前面试时候,面试官问过我后端有没有跨域问题,但是不敢肯定,现在可以肯定的说没有. 不文用php的cURL和file_get_contents方法分别实现后端跨域.本文场景也是在tp5下实现的. 一, ...

  3. 相机上的P,S,A,M分别是什么单词的缩写?

    程序曝光 Programmed Auto快门优先 Shutter Priority光圈优先 aperture-priority 全手动模式 Manual Mode

  4. nginx 设置默认虚拟 host

    nginx 设置默认虚拟 host listren 80 default_server

  5. WriteLine(ls.ToString());Console.WriteLine(ls);输出结果相同,为什么要加 .ToString()

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Test ...

  6. BZOJ 1221 软件开发(费用流)

    容易看出这是显然的费用流模型. 把每天需要的餐巾数作为限制.需要将天数拆点,x’表示每天需要的餐巾,x’’表示每天用完的餐巾.所以加边 (s,x',INF,0),(x'',t,INF,0). 餐巾可以 ...

  7. BZOJ4299 Codechef FRBSUM(主席树)

    感觉非常不可做,于是考虑有什么奇怪的性质. 先考虑怎么求子集和mex.将数从小到大排序,假设已经凑出了0~n的所有数,如果下一个数>n+1显然mex就是n+1了,否则若其为x则可以凑出1~n+x ...

  8. 【Luogu】P2901牛慢跑(K短路模板)

    题目链接 K短路居然用A*……奇妙. 先建反图从终点(1)跑一遍最短路,再A*,用堆存当前点到终点距离+从起点到当前点距离. 每次取出终点都可以视为发现了一个新的最短路. #include<cs ...

  9. Hadoop运行Jar文件时Output错误

    当第二次运行Jar程序时,出现Output文件已存在的Exception: Exception in thread "main" org.apache.hadoop.mapred. ...

  10. POJ1236:Network of Schools——题解

    http://poj.org/problem?id=1236 首先还是缩点,然后入度为0的点的个数就是你要投文件个数. 然后我们对于入度和出度为0的点的个数取最大值即为答案. (简单证明:入度和出度为 ...