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 ...
随机推荐
- 通过修改基表(link$)让非public dblink变为public
有些朋友创建了一个非public的dblink,现在该数据库的其他用户需要去使用该dblink,在正常情况下无访问权限,需要重新建一个dblink,或者将原dblink修改为public.但是由于忘记 ...
- kafka深入研究(六)
Kafka Producer端封装自定义消息 Kafka.network包源码解读 Kafka Consumer端的一些解惑 Kafka producer使用注意 kafka0.8的一些变动,先收藏, ...
- Apache2.2.16+PHP5.3.3+MySQL5.1.49的配置方法
第一步:下载安装的文件 1. MySQL:下载地址mysql-5.1.49-win32.msi: 2. Apache: 下载地址httpd-2.2.16-win32-x86-openssl-0.9.8 ...
- C++ 竞赛常用头文件
C.传统 C++ #include <assert.h> 设定插入点 #include <ctype.h> 字符处理 #include <errno.h> 定义错误 ...
- Cesium应用篇:1快速搭建 【转】
范例中所有范例可以在Github中搜索:ExamplesforCesium Cesium ['siːzɪəm]是一款开源的JavaScript开源库,开发者通过Cesium,实现无插件的创建三维球和二 ...
- a标签默认颜色
<a href="www.baidu.com">test</a> <span style="color:#428bca;"> ...
- scala 学习笔记四 匿名函数
1.介绍 Scala 中定义匿名函数的语法很简单,箭头左边是参数列表,右边是函数体. 使用匿名函数后,我们的代码变得更简洁了. 下面的表达式就定义了一个接受一个Int类型输入参数的匿名函数: var ...
- 全局 Style
1.定义一个全局资源文件,如下 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/pres ...
- (转)Overview : Writing Scripts in C# 使用C#书写脚本
Apart from syntax, there are some differences when writing scripts in C# or Boo. Most notable are: 除 ...
- Oracle 错误收集
Oracle 错误大全 ORA-00001: 违反唯一约束条件 (.)ORA-00017: 请求会话以设置跟踪事件ORA-00018: 超出最大会话数ORA-00019: 超出最大会话许可数ORA-0 ...