hdu _1070_结构体排序
来源:互联网 发布:linux alias 参数 编辑:程序博客网 时间:2024/06/12 20:47
Milk
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.
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.
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
2
2
Yili 10 500
Mengniu 20 1000
4
Yili 10 500
Mengniu 20 1000
Guangming 1 199
Yanpai 40 10000
Sample Output
Mengniu
蛇皮 第六天就不喝了
#include<cstdio>#include<iostream>#include<string>#include<algorithm>using namespace std;const int N=30030;int gcd(int x,int y){ return x%y==0 ? y:gcd(y,x%y);}struct node{ string str; double price,volume;} num[2111];bool cmp(node a,node b){ if(a.price!=b.price) return a.price<b.price; else return a.volume>b.volume;}int main(){ int t; while(cin>>t) { while(t--) { int n,i,j; double a,b; cin>>n; for(i=0; i<n; i++) { cin>>num[i].str>>a>>b; int tt=b/200; if(tt<=0) num[i].price=9999999; else if(tt<6) num[i].price=a*1.0/tt; else num[i].price=a*1.0/5; num[i].volume=b; } sort(num,num+n,cmp); // puts("*************");// for(int i=0;i<n;i++) // cout<<num[i].str<<" "<<num[i].price<<" "<<num[i].volume<<endl; cout<<num[0].str<<endl; } } return 0;}
- hdu _1070_结构体排序
- hdu 1785 结构体排序
- hdu 1070(结构体排序)
- HDU 1236 结构体排序
- hdu 1263 结构体排序
- HDU 2093 考试排名---结构体排序
- hdu 4310 Hero(贪心 结构体排序)
- HDU 1263 水果(结构体排序)
- HDU 1236 排名 (排序+结构体)
- hdu 2093 考试排名(结构体排序)
- 【结构体排序】hdu 2409 Team Arrangement
- Hdu 2093(三级结构体排序)
- 【HDU 5499】+ sort 结构体排序
- hdu Problem-5702(结构体排序)
- HDU 2093 考试排名【结构体排序】
- HDU-1070 Milk 结构体排序
- HDU 1862 EXCEL排序(结构体排序)
- HDU--杭电--1177--"Accepted today?"--结构体排序
- HDFS管理工具HDFS Explorer
- 生信脚本练习(9)合并文件 ②
- socket理解
- Android热补丁动态修复技术(二):实战!CLASS_ISPREVERIFIED问题!
- TODO xml
- hdu _1070_结构体排序
- malloc 背后的系统知识
- 0807memo
- 算法系列——Remove Duplicates from Sorted Array II
- UML类图中,多重性的问题数字问题详解
- 『图论』LCA 最近公共祖先
- Runnable、Callable、Future、FutureTask
- UVA 1627 【二分图判定+背包问题】
- python 时间格式转换