Milk

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 15697    Accepted Submission(s): 3947

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.
 
这个题目当时acm入门的时候,怎么也解决不了 。大水题一直搁置到现在。现在闲着没事干,a它分分秒。看着曾经提交的code,代码质量令今天的我非常是感概。 又臭又长。而且回忆起曾经解这个题目时遇到的思路问题,感觉acm确实能给人带来思维上的强大进步,特别特别明显。 想问题也想的非常清楚。事实上这个题目就是简单的把问题划分清楚就ok了,同一时候注意点儿细节。
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
struct ls
{
string str;
int mo;
int ml;
double rate;
} gq[1000];
bool cmp(ls co,ls cn)
{
return co.rate<cn.rate;
}
int main()
{
int T,n;
cin>>T;
while(T--)
{
cin>>n;
for(int i=0; i<n; i++)
{
cin>>gq[i].str>>gq[i].mo>>gq[i].ml; if(gq[i].ml>=1200)
gq[i].rate=gq[i].mo/5;
else if((gq[i].ml>=200))
{
int x=(gq[i].ml)/200;
gq[i].rate=gq[i].mo/double(x*1.0);
}
else
gq[i].rate=-1;
}
double Min=0x1f1f1f1f;
int k;
for(int j=0; j<n; j++)
{
if(gq[j].rate!=-1)
{
if(gq[j].rate<Min)
{
Min=gq[j].rate;
k=j;
}
}
}
cout<<gq[k].str<<endl;
}
return 0;
}
/*
2
2
Yili 10 500
Mengniu 20 1000
4
Yili 10 600
Mengniu 20 1000
Guangming 1 199
Yanpai 40 10000
**/

杭电 HDU ACM Milk的更多相关文章

  1. 杭电 HDU ACM 2795 Billboard(线段树伪装版)

    Billboard Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  2. 杭电 HDU ACM 1698 Just a Hook(线段树 区间更新 延迟标记)

    欢迎"热爱编程"的高考少年--报考杭州电子科技大学计算机学院 Just a Hook Time Limit: 4000/2000 MS (Java/Others)    Memor ...

  3. ACM 杭电HDU 2084 数塔 [解题报告]

    数塔 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submissi ...

  4. 杭电 HDU 4608 I-number

    http://acm.hdu.edu.cn/showproblem.php?pid=4608 听说这个题是比赛的签到题......无语..... 问题:给你一个数x,求比它大的数y. y的要求: 1. ...

  5. 深搜基础题目 杭电 HDU 1241

    HDU 1241 是深搜算法的入门题目,递归实现. 原题目传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1241 代码仅供参考,c++实现: #incl ...

  6. 杭电 HDU 1242 Rescue

    http://acm.hdu.edu.cn/showproblem.php?pid=1242 问题:牢房里有墙(#),警卫(x)和道路( . ),天使被关在牢房里位置为a,你的位置在r处,杀死一个警卫 ...

  7. 杭电 HDU 1031 Design T-Shirt

    Design T-Shirt Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) T ...

  8. 杭电hdu 2089 数位dp

    杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer). 杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍 ...

  9. 杭电 HDU 2717 Catch That Cow

    Catch That Cow Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) T ...

随机推荐

  1. SQLite中不支持的sql语法

    今天很自然的在写Sql语句的时候用了Top,一开始没发现问题,因为我从数据库读出的值正好是0,而我习惯变量定义的时候也都赋值0,可是到我不要0的时候我就发现问题了.后来才知道,可爱的小sqlite竟然 ...

  2. tomcat端口号、日志、启停

    cd到tomcat目录下 1.[root@rusky bin]# ./shutdown.sh         关闭tomcat 2.[root@rusky bin]# ./startup.sh     ...

  3. OD: Heap Exploit : DWORD Shooting & Opcode Injecting

    堆块分配时的任意地址写入攻击原理 堆管理系统的三类操作:分配.释放.合并,归根到底都是对堆块链表的修改.如果能伪造链表结点的指针,那么在链表装卸的过程中就有可能获得读写内存的机会.堆溢出利用的精髓就是 ...

  4. jquery中attr与pror

  5. (转).NET平台开源JSON库LitJSON的使用方法

    一个简单示例: String str = "{’name’:’cyf’,’id’:10,’items’:[{’itemid’:1001,’itemname’:’hello’},{’itemi ...

  6. sqlserver获取当前id的前一条数据和后一条数据

    一.条件字段为数值的情况   select * from tb where id=@id; --当前记录   select top 1 * from tb where id>@id order  ...

  7. window下Slik SVN的安装配置

    我相信各位都应该对SVN不会陌生吧,我相信绝大多数人都使用过,但是并不是人人都自己配置过SVN服务器.下面就是我配置SVN服务器的步骤,以及在配置过程中碰见的一些问题,在此记录,希望对你有所帮助. 安 ...

  8. ie6里png图片不透明

    ie6下img图片或背景图片为png时,图片变成了一片黑色: 图中的jquery-timepicker的两个黑方块和img就是由此原因引用的.解决方法:由Drew Diller提供,对img.back ...

  9. 参数解析argparse模块

    argparse,python的一个命令行解析模块 import argparse #创建一个命令行解析器 parser = argparse.ArgumentParser() #增添参数 parse ...

  10. MobileProject

    iOS开源项目MobileProject功能点介绍 一:MobileProject简介 MobileProject项目是一个以MVC模式搭建的开源功能集合,基于Objective-C上面进行编写,意在 ...