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 ...
随机推荐
- java使用POI获取sheet、行数、列数
FileInputStream inp = new FileInputStream("E:\\WEIAN.xls"); HSSFWorkbook wb = new HSSFWork ...
- JavaScript 面向对象编程之一
一:Class and private And public JS 中的类以 function 进行声明,同时 JS 也支持声明私有 private 和公有 public 成员,只不过跟 C# 不一样 ...
- php扩展开发笔记(2)多个源代码文件的配置和编译
我们在开发过程中,为了代码得可读性和易维护性,肯定是须要多个代码文件的,而不不过通过 ext_skel 生成得骨架文件. 这篇文章主要介绍下.多个代码文件的时候.我们须要注意什么,以及怎么做. 我的代 ...
- C语言:使用realloc函数对malloc或者calloc动态分配的内存大小进行扩展
#include<stdio.h> #include<stdlib.h> #include<time.h> typedef struct { char name[3 ...
- 3D屏保程序:汉诺塔
学过程序的人一定记得汉诺塔.我们学的第一个程序是HelloWorld,而碰到的第一个坑就是汉诺塔,短短十几行代码,不知花费了多少时间精力去理解.我记得当年的开发环境还是蓝屏的,汉诺塔程序的输出还是一行 ...
- C/C++ 读取16进制文件
1.为什么有这种需求 因为有些情况需要避免出现乱码.不管什么编码都是二进制的,这样表示为16进制就可以啦. 2.如何读取16进制文件 最近编程用这一问题,网上查了一下,感觉还是自己写吧. 16进制数据 ...
- [转]linux sort 命令详解
原文网址:http://www.cnblogs.com/51linux/archive/2012/05/23/2515299.html 1 sort的工作原理 sort将文件的每一行作为一个单位,相互 ...
- " 初窥 " nginx
1. 无题 第一次听到Nginx这个词,还是两年前的事儿了,最近常逛CSDN,越来越频繁的接触到这个词汇,今天看了些资料,简单的总结下,作为入门. 2. 背景介绍: Nginx (发音同 engine ...
- iframe跨域与session失效问题
何为跨域跨域session/cookie? 也就是第三方session/cookie.第一方session/cookie指的是访客当前访问的网站给访客的浏览器设置的seesion /cookie, 会 ...
- Druid对比Elasticsearch
我们不是Elasticsearch的专家, 如果描绘有误, 请通过邮件列表或者其他途径告知我们. Elasticsearch 是基于Apache Lucene搜索服务器. 提供了对无模式文档的全文检 ...