hdu 1070 Milk

简介:

 

     很简单的一题,就是要注意下要求:

     1.一瓶奶只喝5天,也就是即使再多也只喝1000ml

     2.当低于200ml时就会被扔了,也就是算性价比时有效的就是200的倍数。

     3.如果一开始就少于200ml就直接不会买

     考虑了这几点后还有性价比,因为double有效精度有限,而没有容量上限,所以最好算单位价格奶的容积,而不是多少升几元……

 

/*
author:jxy
lang:C/C++
university:China,Xidian University
**If you need to reprint,please indicate the source**
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#define INF 1E9
using namespace std;
string ans;
int Maxv;
double price;
int main()
{
    int T,n,i,v,V,p;
    string t;
    double tt;
    scanf("%d",&T);
    while(T--)
    {
        Maxv=0;price=0;
        scanf("%d",&n);
        for(i=0;i<n;i++)
        {
            cin>>t;
            scanf("%d%d",&p,&v);
            if(v<200)continue;
            if(v>1000)V=1000;
            else V=v;
            V=V/200*200;
            tt=(double)V/p;
            if(tt>price)
            {
                price=tt;
                ans=t;
                Maxv=v;
            }
            else if(tt==price)
                if(v>Maxv){Maxv=v;ans=t;}
        }
        cout<<ans<<endl;
    }
}


 

目录
相关文章
|
7月前
|
安全
Leetcode 198. House Robber
一句话理解题意,有个偷马贼晚上要偷尽可能值钱的马,但连续两头马被偷会触发报警,问他如何在不触发报警(不偷连续的两匹马)的情况下偷到总价值最高马,返回最高总价值。
34 3
|
安全
LeetCode 213. House Robber II
你是一个专业的小偷,计划偷窃沿街的房屋,每间房内都藏有一定的现金。这个地方所有的房屋都围成一圈,这意味着第一个房屋和最后一个房屋是紧挨着的。同时,相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警。 给定一个代表每个房屋存放金额的非负整数数组,计算你在不触动警报装置的情况下,能够偷窃到的最高金额。
59 0
LeetCode 213. House Robber II
LeetCode 337. House Robber III
在上次打劫完一条街道之后和一圈房屋后,小偷又发现了一个新的可行窃的地区。这个地区只有一个入口,我们称之为“根”。 除了“根”之外,每栋房子有且只有一个“父“房子与之相连。一番侦察之后,聪明的小偷意识到“这个地方的所有房屋的排列类似于一棵二叉树”。 如果两个直接相连的房子在同一天晚上被打劫,房屋将自动报警。 计算在不触动警报的情况下,小偷一晚能够盗取的最高金额。
44 0
LeetCode 337. House Robber III
Leetcode:House Robber II
Leetcode:House Robber II
104 0
Leetcode:House Robber II
hdu-1098 Ignatius's puzzle(费马小定理)
hdu-1098 Ignatius's puzzle(费马小定理)
133 0
hdu-1098 Ignatius's puzzle(费马小定理)
【LeetCode】House Robber III(337)
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all houses in this place forms a binary tree". It will automaticall
85 0
|
存储 算法 测试技术