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. redis安装过程中遇到的问题

    正常的 wget http://download.redis.io/releases/redis-3.0.7.tar.gz下载 解压缩 tar -zxvf redis-3.0.7.tar.gz cd ...

  2. (转)ligerUI 使用教程之Tip介绍与使用

    概述:   ligertip是ligerUI系列插件中的tooltip类插件,作用是弹一个浮动层,起提示作用   阅读本文要求具备jQuery的基本知识,不然文中的javascript代码不易理解 截 ...

  3. MySql事务及隔离级别

    在数据库中,所谓事务是指作为单个逻辑工作单元执行的一系列操作. 事务的操作: 先定义开始一个事务,然后对数据作修改操作, 这时如果提交(COMMIT),这些修改就永久地保存下来 如果回退(ROLLBA ...

  4. dede后台反应特别慢-转

    找到织梦后台管理目录下的/templets/index_body.htm文件 将第25行至第35行部分js代码注释掉. 就这么简单

  5. python学习第九天 -- 列表生产式

    说说python特有的列表生成式.python的列表的生成式主要用法是什么? 用法就是可以使用简洁的代码生成出list集合. 直接用代码举了例子: 利用列表生成式生成列表[1x2,3x4,5x6,7x ...

  6. Python 一路走来 HTML CSS Javascript

    前端三把利器 HTML          -标签 (成对写不容易忘记闭合)                     自闭和标签           标签里写个 xx=xx, 表示标签的属性       ...

  7. JS中的phototype是JS中比较难理解的一个部分

    本文基于下面几个知识点: 1 原型法设计模式 在.Net中可以使用clone()来实现原型法 原型法的主要思想是,现在有1个类A,我想要创建一个类B,这个类是以A为原型的,并且能进行扩展.我们称B的原 ...

  8. EE就业最好的方向是转CS,其次是VLSI/ASIC DESIGN & VERIFICATION

    Warald在2012年写过一篇文章<EE现在最好就业的方向是VLSI/ASIC DESIGN VERIFICATION>,三年过去了,很多学电子工程的同学想知道现在形势如何. 首先,按照 ...

  9. 哪些产品不用开发原生APP,微信公众号就够了?

    最近一阶段H5技术被推到高峰,很多人认为借助H5就能利用微信公众号取代APP原生应用了,而事实是怎么样的?这里我从产品层做一个客观分析. 一,原生APP总体趋势 要谈APP是否会被微信取代,那么必须回 ...

  10. 玩Linux桌面发现一个最佳的组合配置

    其实前段时间玩Arch,其实不难,主要是太浪费时间配置折腾了,学到有用的东西太少,不能让我快速进入编程工作的状态,(真不知道有些人用Gentoo和Arch都能用出优越感了,就因为难安装和配置??)但是 ...