codeforces-919A Supermarket

原创 2018年04月17日 21:17:30
A. Supermarket
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

We often go to supermarkets to buy some fruits or vegetables, and on the tag there prints the price for a kilo. But in some supermarkets, when asked how much the items are, the clerk will say that a yuan for b kilos (You don't need to care about what "yuan" is), the same as a / b yuan for a kilo.

Now imagine you'd like to buy m kilos of apples. You've asked n supermarkets and got the prices. Find the minimum cost for those apples.

You can assume that there are enough apples in all supermarkets.

Input

The first line contains two positive integers n and m (1 ≤ n ≤ 5 000, 1 ≤ m ≤ 100), denoting that there are n supermarkets and you want to buy m kilos of apples.

The following n lines describe the information of the supermarkets. Each line contains two positive integers a, b (1 ≤ a, b ≤ 100), denoting that in this supermarket, you are supposed to pay a yuan for b kilos of apples.

Output

The only line, denoting the minimum cost for m kilos of apples. Please make sure that the absolute or relative error between your answer and the correct answer won't exceed 10 - 6.

Formally, let your answer be x, and the jury's answer be y. Your answer is considered correct if .

Examples
Input
Copy
3 5
1 2
3 4
1 3
Output
Copy
1.66666667
Input
Copy
2 1
99 100
98 99
Output
Copy
0.98989899
Note

In the first sample, you are supposed to buy 5 kilos of apples in supermarket 3. The cost is 5 / 3 yuan.

In the second sample, you are supposed to buy 1 kilo of apples in supermarket 2. The cost is 98 / 99 yuan.

#include <iostream>
#include <cstring>
#include <iomanip>
using namespace std;
class decimal{
public :
    int up,down;
    decimal(){};
    decimal(int,int);
    friend bool operator>(decimal,decimal);
};
decimal::decimal(int x,int y){
    up=x;
    down=y;
}
bool operator>(decimal x,decimal y){
    return x.up*y.down>x.down*y.up;
}
int main(){
    int n,m;
    while(cin>>n>>m){
        decimal now,minn(101,1);
        for(int i=0;i<n;i++){
            cin>>now.up>>now.down;
            if(minn>now){
                minn=now;
            }
        }
        cout<<fixed<<setprecision(8)<<m*minn.up*1.0/minn.down<<endl;
    }
    return 0;
}

POJ-1456 Supermarket【贪心】

题目链接:http://poj.org/problem?id=1456 题目大意: 有N件商品,分别给出商品的价值和销售的最后期限,只要在最后日期之前销售处,就能得到相应的利润,并且销售该商品需要...
  • niushuai666
  • niushuai666
  • 2012-01-06 10:03:21
  • 5145

Codeforces 816E Karen And SuperMarket 树形背包

点击打开链接 题意:有n件商品,每件有价格ci,优惠券di,对于i>=2,使用di的条件为:xi的优惠券需要被使用,问初始金钱为b时 最多能买多少件商品? n 因为(i>=2时)每个优...
  • Jeremy1149
  • Jeremy1149
  • 2017-06-20 13:28:05
  • 808

919A. Supermarket

A. Supermarket time limit per test 2 seconds memory limit per test 256 megabytes input standar...
  • memory_qianxiao
  • memory_qianxiao
  • 2018-01-31 23:29:01
  • 45

A. Supermarket

time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
  • jj12345jj198999
  • jj12345jj198999
  • 2018-02-03 19:49:00
  • 155

Codeforces Round #460 (Div. 2)-A. Supermarket

A. Supermarkettime limit per test2 seconds memory limit per test256 megabytesProblem DescriptionWe ...
  • yopilipala
  • yopilipala
  • 2018-02-01 14:21:21
  • 120

POJ1456 Supermarket简单贪心(无优化)题解

POJ原题地址:http://poj.org/problem?id=1456 看完题目很容易就想到,花一个单位时间获得最大的利润是最划算的,于是我们的工作就是往每个单位时间填充最大的利润,也就是贪心...
  • C20161009
  • C20161009
  • 2016-01-25 11:15:12
  • 664

poj Supermarket(贪心)(并查集)(优先队列)

Supermarket Description A supermarket has a set Prod of products on sale. It earns a profit px fo...
  • blessLZH0108
  • blessLZH0108
  • 2017-03-08 21:48:50
  • 327

POJ1456Supermarket(贪心+优先队列)

Supermarket Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9103   Ac...
  • u010372095
  • u010372095
  • 2014-08-11 22:47:52
  • 1390

基于.net+sql2000的supermarket源码

  • 2010年07月09日 14:56
  • 1.15MB
  • 下载

cf 815C Karen and Supermarket 树形dp

题目链接点这里 把他看成一棵树,dp[i][j][k]是对于j点用不用优惠券(i)已选k个的最小花费。。。很明显对子树做一个分组背包即可。然而乍一看分组背包的复杂度不是n(n个点)*n*n(dp复杂...
  • qq_30927651
  • qq_30927651
  • 2017-06-21 21:12:37
  • 311
收藏助手
不良信息举报
您举报文章:codeforces-919A Supermarket
举报原因:
原因补充:

(最多只允许输入30个字)