hdu 1070 Milk(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1070
Milk
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 14286 Accepted Submission(s):
3525
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.
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.
milk which is the cheapest. If there are more than one cheapest brand, you
should output the one which has the largest volume.
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 <cstdio>
#include <cstring>
using namespace std; int main()
{
char name[],min_name[];
double Min,s;
int min_v;
int T,p,v,d,n;
scanf("%d",&T);
while (T--)
{
Min=;
min_v=;
scanf("%d",&n);
while(n--)
{
scanf("%s%d%d",name,&p,&v);
if (v<)
continue;
if (v/>=)
s=p/;
else
s=p*1.0/(v/);
if(Min>s)
{
min_v=v;
Min=s;
strcpy(min_name,name);
}
else if(Min==s)
{
if(min_v<v)
{
min_v=v;
strcpy(min_name,name);
}
}
}
printf("%s\n",min_name);
}
return ;
}
hdu 1070 Milk(贪心)的更多相关文章
- HDU 1070 Milk (模拟)
题目链接 Problem Description Ignatius drinks milk everyday, now he is in the supermarket and he wants to ...
- HDU 1070 - Milk
给每种牛奶价格和量 要求买最便宜的牛奶 #include <iostream> using namespace std; int t,n; ][]; ],v[]; int main() { ...
- Hdu 4864(Task 贪心)(Java实现)
Hdu 4864(Task 贪心) 原题链接 题意:给定n台机器和m个任务,任务和机器都有工作时间值和工作等级值,一个机器只能执行一个任务,且执行任务的条件位机器的两个值都大于等于任务的值,每完成一个 ...
- D - 淡黄的长裙 HDU - 4221(贪心)
D - 淡黄的长裙 HDU - 4221(贪心) James is almost mad! Currently, he was assigned a lot of works to do, so ma ...
- HDOJ.1070 Milk(贪心)
Milk 点我挑战题目 题意分析 每组测试数据给出一系列牛奶商品,分别是牛奶的品牌,价格,以及体积.在读取数据的时候,体积在200以下的牛奶直接忽略掉.并且每天要喝200ML的牛奶.但是无论牛奶体积有 ...
- hdu 2037简单贪心--活动安排问题
活动安排问题就是要在所给的活动集合中选出最大的相容活动子集合,是可以用贪心算法有效求解的很好例子.该问题要求高效地安排一系列争用某一公共资源的活动.贪心算法提供了一个简单.漂亮的方法使得尽可能多的活动 ...
- HDU 4864 Task (贪心+STL多集(二分)+邻接表存储)(杭电多校训练赛第一场1004)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4864 解题报告:有n台机器用来完成m个任务,每个任务有一个难度值和一个需要完成的时间,每台机器有一个可 ...
- HDU 4310 Hero (贪心算法)
A - Hero Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Sta ...
- hdu 4268 multiset+贪心
Alice和Bob有n个长方形,有长度和宽度,一个矩形可以覆盖另一个矩形的条件的是,本身长度大于等于另一个矩形,且宽度大于等于另一个矩形,矩形不可旋转,问你Alice最多能覆盖Bob的几个矩形? /* ...
随机推荐
- PAT 甲级 1012 The Best Rank
https://pintia.cn/problem-sets/994805342720868352/problems/994805502658068480 To evaluate the perfor ...
- Spyder5 & 显示器校准 & 色彩校准
Spyder5 & 显示器校准 & 色彩校准 Spyder5EXPRESS 绿蜘蛛5 – 轻松.快速地校准您的屏幕. Spyder5PRO 蓝蜘蛛5 – 可为您的所有笔记本电脑和台式机 ...
- RT-thread内核之空闲线程
空闲线程是系统线程中一个比较特殊的线程,它具有最低的优先级,当系统中无其他线程可运行时,调度器将调度到空闲线程.空闲线程通常是一个死循环,永远不被挂起.RT-Thread实时操作系统为空闲线程提供了钩 ...
- 只要访问的地址匹配cookie的地址时候 发送request请求时候 会携带上该cookie
只要访问的地址匹配cookie的地址时候 发送request请求时候 会携带上该cookie
- NAT穿透(UDP打洞)
1.NAT(Network Address Translator)介绍 NAT有两大类,基本NAT和NAPT. 1.1.基本NAT 静态NAT:一个公网IP对应一个内部IP,一对一转换 动态NAT:N ...
- hdu 2108 Shape of HDU (数学)
Shape of HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- CentOS 安装MariaDB
1.安装 #同时安装mariadb和mariadb-server [root@bigdata-senior01 yum.repos.d]# yum -y install mariadb mariadb ...
- HDU - 6333 Harvest of Apples
题意: T次询问,每次给出n,m.求sigma(k:0->m)C(n, k). 题解: 用离线莫队来做. 令S(n,m) = sigma(k:0->m)C(n, k). S(n+1, m) ...
- 容器化RDS|计算存储分离 or 本地存储?
随着交流机会的增多(集中在金融行业,规模都在各自领域数一数二),发现大家对 Docker + Kubernetes 的接受程度超乎想象, 并极有兴趣将这套架构应用到 RDS 领域.数据库服务的需求可以 ...
- ural1297 求最长回文子串 | 后缀数组
#include<cstdio> #include<algorithm> #include<cstring> #define N 20005 using names ...