杭电 HDU ACM Milk
Milk
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 15697 Accepted Submission(s): 3947
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.
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.
2
2
Yili 10 500
Mengniu 20 1000
4
Yili 10 500
Mengniu 20 1000
Guangming 1 199
Yanpai 40 10000
Mengniu
MengniuHintIn 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的更多相关文章
- 杭电 HDU ACM 2795 Billboard(线段树伪装版)
Billboard Time Limit: 20000/8000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 杭电 HDU ACM 1698 Just a Hook(线段树 区间更新 延迟标记)
欢迎"热爱编程"的高考少年--报考杭州电子科技大学计算机学院 Just a Hook Time Limit: 4000/2000 MS (Java/Others) Memor ...
- ACM 杭电HDU 2084 数塔 [解题报告]
数塔 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submissi ...
- 杭电 HDU 4608 I-number
http://acm.hdu.edu.cn/showproblem.php?pid=4608 听说这个题是比赛的签到题......无语..... 问题:给你一个数x,求比它大的数y. y的要求: 1. ...
- 深搜基础题目 杭电 HDU 1241
HDU 1241 是深搜算法的入门题目,递归实现. 原题目传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1241 代码仅供参考,c++实现: #incl ...
- 杭电 HDU 1242 Rescue
http://acm.hdu.edu.cn/showproblem.php?pid=1242 问题:牢房里有墙(#),警卫(x)和道路( . ),天使被关在牢房里位置为a,你的位置在r处,杀死一个警卫 ...
- 杭电 HDU 1031 Design T-Shirt
Design T-Shirt Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- 杭电hdu 2089 数位dp
杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer). 杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍 ...
- 杭电 HDU 2717 Catch That Cow
Catch That Cow Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) T ...
随机推荐
- Android浏览图片,点击放大至全屏效果
做到照片浏览的功能,对于QQ空间中点击图片放大至全屏,感觉效果很赞,于是也做了个类似的效果.如下. 我不知道QQ那个是怎么做的,我的思路如下: 首先,从图片缩略界面跳转到图片详情页面,应该是从一个Ac ...
- Java基础知识强化37:StringBuffer类之StringBuffer的构造方法
1. StringBuffer的构造方法: (1)StringBuffer(): (2)StringBuffer(CharSequence seq): (3)StringBuffer(int capa ...
- Java设计模式---工厂模式(简单工厂、工厂方法、抽象工厂)
工厂模式:主要用来实例化有共同接口的类,工厂模式可以动态决定应该实例化那一个类.工厂模式的形态工厂模式主要用一下几种形态:1:简单工厂(Simple Factory).2:工厂方法(Factory M ...
- 重学《C#高级编程》(继承)
前两天重新看了<C#高级编程>里的第四章:继承与第六章:数组.OOP三大特性:封装,继承,多态,个人感觉继承是实现多态的基础,包括以后接触的设计模式,都是继承特性的衍生. 继承特性有两种, ...
- HTML、CSS、JS、PHP 的学习顺序~(零基础初学者)
如果你有耐心坚持一年以上的话, 我会推荐HTML->CSS->JS->PHP的顺序来学习. 1. HTML学习:首先学习HTML,HTML作为标记语言是非常容易学的,把w3schoo ...
- 23 读取excel
/** index mappingname originalname datatype family 0 task_id taskIndexCode STRING info 1 task_type r ...
- linux int to string 方法
最近从windows 移植程序的时候发现to_string()函数在linux 中不能用,网上找了几种方法,觉得使用stringstream对象来实现类型转化比较好一点. 你只需在你工程中加入下面的t ...
- (原)torch的训练过程
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6221622.html 参考网址: http://ju.outofmemory.cn/entry/284 ...
- JS将毫秒转换成时间格式
JavaScript Date(日期)对象 实例 getTime():返回从 1970 年 1 月 1 日至今的毫秒数. setFullYear(): 设置具体的日期. toUTCString():将 ...
- nvm linux命令
nvm alias default 0.12.10 nvm alias default 0.10.24 nvm list NVM_NODEJS_ORG_MIRROR=http://npm.taobao ...