hdu1070Milk
来源:互联网 发布:如何成为淘宝模特 编辑:程序博客网 时间:2024/06/05 16:27
Milk
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 19525 Accepted Submission(s): 5081
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.
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.
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
22Yili 10 500Mengniu 20 10004Yili 10 500Mengniu 20 1000Guangming 1 199Yanpai 40 10000
Sample Output
MengniuMengniuHintIn 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 <cstdio>#include <cstring>using namespace std;struct node{ string s; int p,l; double e; int day;} s[1010];int main(){ int min,t,n,k; scanf("%d",&t); while(t--) { scanf("%d",&n); min=999999; k=0; for(int i=0; i<n; i++) { cin>>s[i].s>>s[i].p>>s[i].l; if(s[i].l<200) continue; s[i].day=s[i].l/200; if(s[i].day>=6)s[i].day=5; s[i].e=s[i].p/s[i].day*1.0; if(min>s[i].e) { min=s[i].e; k=i; } if(min==s[i].e) { if(s[i].l>s[k].l) { min=s[i].e; k=i; } } } cout<<s[k].s<<endl; } return 0;}/*#include<iostream>#include<string>using namespace std;struct milk{ string s; int p; int v; double e; int day;}d[1000];int main(){ int t,n,i,j; double min; while(cin>>t) { while(t--&&cin>>n) { min=999999; j=0; for(i=0;i<n;i++) { cin>>d[i].s>>d[i].p>>d[i].v; if(d[i].v<200)continue; d[i].day=d[i].v/200; if(d[i].day>=6)d[i].day=5; d[i].e=d[i].p/d[i].day*1.0; if(min>d[i].e){min=d[i].e;j=i;} if(min==d[i].e) { if(d[i].v>d[j].v) { min=d[i].e; j=i; } } } cout<<d[j].s<<endl; } } return 0;}*/
Author
0 0
- hdu1070Milk
- hdu1070Milk
- 二叉排序树
- HDU 2196 Computer(树状DP)
- SGU 149 Computer Network 树状DP求单点到树的最大距离
- 图解Sqlite教程2
- 漫步微积分二十一——不定积分和换元法
- hdu1070Milk
- python3.3 lxml+beautifulsoup 爬虫说明
- 【搜索】 noi openjudge 2.5 拯救行动
- Android 开发绕不过的坑:你的 Bitmap 究竟占多大内存?
- bjfu1013仙人指路
- python爬取花瓣网图片
- Mysql数据库的使用
- java中的vo 、dto 、dao
- 对称加密与非对称加密