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
  1. 3 5
  2. 1 2
  3. 3 4
  4. 1 3
output
  1. 1.66666667
input
  1. 2 1
  2. 99 100
  3. 98 99
output
  1. 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.




贪心,做商排序即可。

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. template <typename t>
  4. void read(t &x)
  5. {
  6. char ch = getchar();
  7. x = 0;
  8. t f = 1;
  9. while (ch < '0' || ch > '9')
  10. f = (ch == '-' ? -1 : f), ch = getchar();
  11. while (ch >= '0' && ch <= '9')
  12. x = x * 10 + ch - '0', ch = getchar();
  13. x *= f;
  14. }
  15. #define wi(n) printf("%d ", n)
  16. #define wl(n) printf("%lld ", n)
  17. #define rep(m, n, i) for (int i = m; i < n; ++i)
  18. #define rrep(m, n, i) for (int i = m; i > n; --i)
  19. #define P puts(" ")
  20. typedef long long ll;
  21. #define MOD 1000000007
  22. #define mp(a, b) make_pair(a, b)
  23. #define N 10005
  24. #define fil(a, n) rep(0, n, i) read(a[i])
  25. //---------------https://lunatic.blog.csdn.net/-------------------//
  26. #define maxn 5005
  27. struct Pay
  28. {
  29. double w;
  30. double v;
  31. double pri;
  32. } s[maxn];
  33. int cmp(Pay a, Pay b)
  34. {
  35. return a.pri < b.pri;
  36. }
  37. int main()
  38. {
  39. int m, i, n;
  40. Pay s[maxn];
  41. read(m), read(n);
  42. for (i = 0; i < m; i++)
  43. {
  44. scanf("%lf%lf", &s[i].v, &s[i].w);
  45. s[i].pri = s[i].v / s[i].w;
  46. }
  47. sort(s, s + m, cmp);
  48. printf("%.10f", n * s[0].pri);
  49. return 0;
  50. }

Codeforces Round #460 (Div. 2)-A Supermaket(贪心)的更多相关文章

  1. Codeforces Round #202 (Div. 1) A. Mafia 贪心

    A. Mafia Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/348/problem/A D ...

  2. Codeforces Round #382 (Div. 2)B. Urbanization 贪心

    B. Urbanization 题目链接 http://codeforces.com/contest/735/problem/B 题面 Local authorities have heard a l ...

  3. Codeforces Round #164 (Div. 2) E. Playlist 贪心+概率dp

    题目链接: http://codeforces.com/problemset/problem/268/E E. Playlist time limit per test 1 secondmemory ...

  4. Codeforces Round #180 (Div. 2) B. Sail 贪心

    B. Sail 题目连接: http://www.codeforces.com/contest/298/problem/B Description The polar bears are going ...

  5. Codeforces Round #192 (Div. 1) A. Purification 贪心

    A. Purification Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/329/probl ...

  6. Codeforces Round #274 (Div. 1) A. Exams 贪心

    A. Exams Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/480/problem/A Des ...

  7. Codeforces Round #374 (Div. 2) B. Passwords 贪心

    B. Passwords 题目连接: http://codeforces.com/contest/721/problem/B Description Vanya is managed to enter ...

  8. Codeforces Round #303 (Div. 2) C. Woodcutters 贪心

    C. Woodcutters Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/545/probl ...

  9. Codeforces Round #377 (Div. 2) D. Exams 贪心 + 简单模拟

    http://codeforces.com/contest/732/problem/D 这题我发现很多人用二分答案,但是是不用的. 我们统计一个数值all表示要准备考试的所有日子和.+m(这些时间用来 ...

随机推荐

  1. MySQL入门,第七部分,单表查询

    首先我们需要了解一下整个数据库的结构 其中Student表中Sno为主键.Study表中Sno和Cno合起来做主键.Course表中Cno为主键 其创建脚本如下: #----------------- ...

  2. linux系统管理,查看系统资源

    free 查看内存使用情况 -b  ===>  以byte为单位 -k  ===>  以Kb为单位 -m  ===>  以Mb为单位 -g  ===>  以Gb为单位 -t  ...

  3. Linux bash篇(二 操作环境)

    1.命令执行的顺序 (1).相对/绝对路径 (2).由alias找到的命令 (3).由bash内置的命令 (4).通过$PATH变量找到的第一个命令 2.第一篇讲到的bash在注销后就会无效,如果想保 ...

  4. coding++:java 线程池概述

    前言: 1):创建一个可缓存线程池 2):创建一个可重用固定个数的线程池,以共享的无界队列方式来运行这些线程. 3):创建一个定长线程池,支持定时及周期性任务执行 4):创建一个单线程化的线程池,它只 ...

  5. 多数据源系统接入mybatis-plus, 实现动态数据源、动态事务。

    目录: 实现思想 导入依赖.配置说明 代码实现 问题总结 一.实现思想 接手一个旧系统,SpringBoot 使用的是纯粹的 mybatis ,既没有使用规范的代码生成器,也没有使用 JPA 或者 m ...

  6. undefined 和 not defined

    概念上的解释: undefined是javascript语言中定义的五个原始类中的一个,换句话说,undefined并不是程序报错,而是程序允许的一个值. not defined是javascript ...

  7. 2019-05-12 Python之模拟体育竞赛

    一.简介 可以选择任意规则,模拟不同的两个队伍进行球赛的模拟比赛 二.源代码 函数介绍: from random import * #输出介绍信息 def printIntro(): print(&q ...

  8. 深度解密 Go 语言之 sync.Pool

    最近在工作中碰到了 GC 的问题:项目中大量重复地创建许多对象,造成 GC 的工作量巨大,CPU 频繁掉底.准备使用 sync.Pool 来缓存对象,减轻 GC 的消耗.为了用起来更顺畅,我特地研究了 ...

  9. Web三维编程入门总结之三:3D碰撞检测初探

    自己动手写一个方法比分析他人的写的方法困难很多,由此而来的对程序的进一步理解也是分析别人的代码很难得到的. 一.先来几张效果图: 1.场景中有两个半径为1的球体,蓝色线段从球心出发指向球体的“正向” ...

  10. F - Robot Motion 栈加BFS

    A robot has been programmed to follow the instructions in its path. Instructions for the next direct ...