hdoj.1070 Milk 20140807
来源:互联网 发布:js formdata 取属性值 编辑:程序博客网 时间:2024/05/19 04:29
Milk
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 13555 Accepted Submission(s): 3309
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<stdio.h>#include<string.h>#include<algorithm>using namespace std;struct nn{ char name[110]; double price; int ml; };int cmp(nn x,nn y){ int day1,day2; double price1,price2; day1=x.ml>=1000?5:x.ml/200; day2=y.ml>=1000?5:y.ml/200; price1=x.price/day1; price2=y.price/day2; if(price1==price2) return x.ml>y.ml; return price1<price2;}nn niunai[110];int main(){ int T,n,i; while(scanf("%d",&T)!=EOF) { while(T--) { scanf("%d",&n); getchar(); for(i=0;i<n;i++) { scanf("%s %lf %d",niunai[i].name,&niunai[i].price,&niunai[i].ml); getchar(); if(niunai[i].ml<200) { i--;n--; } } sort(niunai,niunai+n,cmp); printf("%s\n",niunai[0].name); } } return 0;}
0 0
- hdoj.1070 Milk 20140807
- 【HDOJ】1070 -> Milk
- hdoj 1070 milk
- HDOJ milk 1070
- HDOJ 1070 Milk
- HDOJ 1070 Milk
- HDOJ 1070 Milk
- HDOJ.1070 Milk(贪心)
- hdoj Milk
- 航电ACM HDOJ 1070 Milk
- HDOJ 1070 Milk(水题,考英文的)
- HDOJ 1070 Milk ( 喝牛奶问题 )
- 1070 Milk
- hdu 1070 Milk(水)
- 杭电1070 Milk
- 水题 hdu 1070 milk
- HDU 1070 Milk
- hdu 1070 Milk
- 蛭石于水泥的使用
- ios--IB介绍(Interface Builder)
- 编程之美--3.10 分层遍历二叉树
- WR703 uboot/带Web的Mod版本/pepe2k 再次Mod版本/修改mac地址
- 进制转换,指针前奏,奇偶互换,左移,右移
- hdoj.1070 Milk 20140807
- Redis主从服务器配置
- poj1840 哈希函数构造学习
- Java 排序之 计数排序
- hdu 1255 覆盖的面积 线段树+离散化
- C++中static的用法总结
- make menuconfig提示'make menuconfig' requires the ncurses libraries.
- java String类源代码
- 图片加载错误代码