HDUOJ----1170Milk
Milk
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 11915 Accepted Submission(s): 2885
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.
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.
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef struct
{
string name;
int day;
int pri;
}go; bool cmp(go const a,go const b)
{
if(a.pri==b.pri)
return a.day>b.day?:;
return a.pri<b.pri?:; }
int main()
{
vector<go>st;
go tem;
int t,n;
cin>>t;
while(t--)
{
cin>>n;
st.clear();
while(n--)
{
cin>>tem.name>>tem.pri>>tem.day;
if(tem.day>) //小于1就忽略
{
if(tem.day>) tem.pri/=;
else
tem.pri/=(tem.day/);
st.push_back(tem);
}
}
sort(st.begin(),st.end(),cmp);
vector<go>::iterator it=st.begin();
cout<<(*it).name<<endl;
}
return ;
}
HDUOJ----1170Milk的更多相关文章
- hduoj 1455 && uva 243 E - Sticks
http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlin ...
- hduoj 4712 Hamming Distance 2013 ACM/ICPC Asia Regional Online —— Warmup
http://acm.hdu.edu.cn/showproblem.php?pid=4712 Hamming Distance Time Limit: 6000/3000 MS (Java/Other ...
- hduoj 4706 Herding 2013 ACM/ICPC Asia Regional Online —— Warmup
hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup Herding Time Limit: 2000/1000 ...
- hdu-oj 1874 畅通工程续
最短路基础 这个题目hdu-oj 1874可以用来练习最短路的一些算法. Dijkstra 无优化版本 #include<cstdio> #include<iostream> ...
- C#版 - HDUoj 5391 - Zball in Tina Town(素数) - 题解
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. HDUoj 5 ...
- C++版 - HDUoj 2010 3阶的水仙花数 - 牛客网
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C++版 - ...
- HDUOJ题目HTML的爬取
HDUOJ题目HTML的爬取 封装好的exe/app的GitHub地址:https://github.com/Rhythmicc/HDUHTML 按照系统选择即可. 其实没什么难度,先爬下来一个题目的 ...
- hduoj 1251 统计难题
http://acm.hdu.edu.cn/showproblem.php?pid=1251 统计难题 Time Limit: 4000/2000 MS (Java/Others) Memory ...
- hduoj 1286 找新朋友
http://acm.hdu.edu.cn/showproblem.php?pid=1286 找新朋友 Time Limit: 2000/1000 MS (Java/Others) Memory Li ...
- hduoj 1285 确定比赛名次
http://acm.hdu.edu.cn/showproblem.php?pid=1285 确定比赛名次 Time Limit: 2000/1000 MS (Java/Others) Memory ...
随机推荐
- [MAC OS] NSButton tag 获取
@IBAction func switchContentLayout(_ sender: Any) { let button : NSButton = sender as! NSButton;}
- 使用Jenkins和Jmeter搭建性能测试平台
参考文档:http://blog.csdn.net/liuchunming033/article/details/52186157 jenkins的性能测试结果展现插件:https://wiki.je ...
- 【BestCoder】【Round#44】
模拟+Trie+桶排(归并?)+容斥 A 模(shou)拟(su)题= =感觉好像见过? 计算得分什么的…… //BestCoder #44 A #include<vector> #inc ...
- IDEA热部署基于maven的web项目
第一步:首先先创建web项目 按照向导一步一步完成项目创建,我创建的示例项目为hotdeploddemo 第二步:设置项目的web资源 下图中的路径要修改正确,指向src/ma ...
- JS操作JSON常用方法
一.JSON字符串的替换 工作经常遇到这样的字符串,如下: 需要经过替换后,才能从字符串转化成JSON对象.这里我们需要用JS实现replaceAll的功能, 将所有的 ' \\" ' 替换 ...
- RUP
RUP随想 [摘要] 本文主要阐述一下我对RUP软件工程思想的看法以及一些感想.我认为软件工程既然是工程,那么纯粹的空谈理论是没有意义的,软件工程需要实干.我认为软件工程的思想实际上和兵法理论是一样的 ...
- Cognos由于JAVA_HOME冲突引起的错误假象
Cognos的安装和配置并不是很复杂,但是对于初次安装的用户来说,还是要注意一些细节,比如JDK问题,今天我们就来阐述一下这个问题 场景1: 作为一个开发人员,很多人是十八般武艺样样精通,难免已经在自 ...
- Font Awesome使用简介
Font awesome是一种用字体来实现图标的CSS插件. 使用方法: 到http://fortawesome.github.io/Font-Awesome/ 下载代码包. 代码包解压到本地后, ...
- [Big Data] Week4B (Basic)
Question 1 Note: In this question, all columns will be written in their transposed form, as rows, to ...
- 【statistics】理想论坛2018-4-25日统计
说明:利用理想论坛爬虫1.07版(http://www.cnblogs.com/xiandedanteng/p/8954115.html) 下载了前十页主贴及子贴,共得到359619条数据,以此数据为 ...