题目链接

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. LintCode-380.两个链表的交叉

    两个链表的交叉 请写一个程序,找到两个单链表最开始的交叉节点. 注意事项 如果两个链表没有交叉,返回null. 在返回结果后,两个链表仍须保持原有的结构. 可假定整个链表结构中没有循环. 样例 下列两 ...

  2. BZOJ 1911 特别行动队(斜率优化DP)

    应该可以看出这是个很normal的斜率优化式子.推出公式搞一搞即可. # include <cstdio> # include <cstring> # include < ...

  3. hadoop 使用map将SequenFile里的小文件解压出来

    上例中将HDFS里小文件通过mapper压缩到一个文件中,本例将这些小文件解压出来. mapreduce可以按SequenceFile的key进行分片. 1.mapper public class M ...

  4. Docker的结构(6-13)

    一.Docker的结构. Docker命令不清楚的时候可以在命令的最后加上--help Docker和虚拟机的区别? 虚拟机的实现原理是:先模拟出一套硬件,然后在这基础上跑一个操作系统,然后在这个操作 ...

  5. BZOJ5319 & 洛谷4559 & LOJ2551:[JSOI2018]军训列队——题解

    https://www.lydsy.com/JudgeOnline/problem.php?id=5319 https://www.luogu.org/problemnew/show/P4559 ht ...

  6. Windows系统中Xshell与Linux连接时遇到的问题

    前提条件:在Windows系统中已经安装了Xshell,并且安装了虚拟机软件和Linux系统 步骤1.在Linux系统中root用户下,使用ifconfig命令查看虚拟系统Linux的IP地址.如图1 ...

  7. 洛谷 P2860 [USACO06JAN]冗余路径Redundant Paths 解题报告

    P2860 [USACO06JAN]冗余路径Redundant Paths 题目描述 为了从F(1≤F≤5000)个草场中的一个走到另一个,贝茜和她的同伴们有时不得不路过一些她们讨厌的可怕的树.奶牛们 ...

  8. 2016多校联合训练1 B题Chess (博弈论 SG函数)

    题目大意:一个n(n<=1000)行,20列的棋盘上有一些棋子,两个人下棋,每回合可以把任意一个棋子向右移动到这一行的离这个棋子最近的空格上(注意这里不一定是移动最后一个棋子),不能移动到棋盘外 ...

  9. POSIX.2 正则表达式

    By francis_hao    Oct 1,2017   这里的正则表达式主要是指扩展正则,也就是egrep(grep -e)用到的正则表达式. 字符 含义 类别说明 | 分割分支,正则表达式会去 ...

  10. ubuntu14.04安装GTX 1080 ti遇到黑屏问题

    实验室给我配置了一个1080ti的卡,那个激动,windows下1000+的FPS,跑分40W,无敌,言归正传,ubuntu14.04下配nvidia 1080的驱动还是出现了很多问题,差点就要重装系 ...