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. jquery之图片上传

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  2. Linux命令 rpm

    rpm -q samba                          --查询程序是否安装rpm -qa | grep httpd  --[搜索指定rpm包是否安装]  --all搜索*http ...

  3. 对于数据操作的SQL语句精粹(长期更新)

    --删除空格 Update [Table] Set [Column]=Replace([Column],' ','') --查出左右和右边带空格的数据 select RTRIM( LTRIM([Col ...

  4. AngularJs练习Demo19 Resource

    @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport&quo ...

  5. linux分区和系统文件和挂载

    要以root用户进入 .查看磁盘情况 lsblk .进行分区 sudo cfdisk /dev/sda 在空闲资源的地方新建分区,然后一步步的走下来就行了,最后选择write,然后quit 重启 .创 ...

  6. 关于vis标记

    原来写题目的时候对vis标记都是先memset在标记,今天看见一个只要每次对T值修改,然后看看等不等于T就可以了,真好!

  7. CI框架中遇见的一些错误和解决方法 笔记

    ps:根据经验不断修改和更新,欢迎指出错误~ 1. An uncaught Exception was encountered Type: Exception Message: Session: Co ...

  8. jquery1.9学习笔记 之层级选择器(二)

    子孙选择器(“祖先 子孙”) 描述:选择所有给出祖先选择器的子孙选择器. 例子: 用蓝色虚线边框标记所有表单子孙元素的输入.表单里的输入框用黄色背景. <!doctype html>< ...

  9. UC/OS操作系统 (转)

    1.和其他一些著名的嵌入式操作系统不同,uC/OS-II在单片机系统中的启动过程比较简单,不像有些操作系统那样,需要把内核编译成一个映像文件写入ROM中,上电复位后,再从ROM中把文件加载到RAM中去 ...

  10. mysql 查询表

    判断表是否存在 SELECT table_name FROM information_schema.TABLES WHERE table_name ='yourname'; 判断存储过程是否存在 se ...