QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#12384. 组合数问题

Statistics

小葱是一名勇士。

小葱踏上了拯救世界的征途。

小葱面前有 $N$ 只大葱怪。

大葱怪很厉害,第 $i$ 只大葱怪攻击力为 $a_i$,防御力为 $d_i$。

小葱的攻击力为 $A$,防御力为 $D$。

小葱打掉第 $i$ 只大葱怪的代价是 $A\cdot d_i+D\cdot a_i$。

小葱打倒很多只大葱怪的代价不是打倒每一只大葱怪的代价之和,而是最大值。

小葱现在需要打倒 $R$ 只大葱怪。

神葱是葱的神,神葱会对小葱打倒 $R$ 只大葱怪做出评价。神葱对小葱打倒 $R$ 只大葱的评价为小葱打倒这 $R$ 只大葱怪所需要的代价除以小葱以同样的攻击力和防御力打倒所有 $N$ 只大葱怪的代价。

神葱是葱的神,所以神葱会在小葱选择了 $R$ 只要被打倒的大葱怪后,设定小葱的攻击力和防御力,使得小葱得到的评价最低。

神葱不希望这个值是负的,所以如果这个值是负的,神葱会强制把它变为 $0$。

小葱是一名勇士。

小葱不会屈服。

小葱需要选择出 $R$ 只大葱怪,使得自己能够从神葱那里得到的评价最高。

小葱求这个评价值。

小葱很善良,所以小葱为你写出了评价值的数学表示:

$$\max_{S\subseteq[N],|S|=R}\left[\min_{A,D\in\mathbb{Z}^+}\frac{\max_{i\in R}\left(A\cdot d_i+D\cdot a_i\right)}{\max_{i\in[N]}\left(A\cdot d_i+D\cdot a_i\right)}\right]$$

输入格式

测试点包含多组数据。

对于每组数据,第一行两个整数代表 $N,R$。

接下来 $N$ 行每行两个实数分别代表 $a_i,d_i$。

输出格式

对于每组数据,一行一个实数代表答案,你需要保证你的答案与标准答案的误差不超过 $10^{-6}$。

样例数据

样例 1 输入

3 3
1 3
2 5
2 3
5 1
1 5
2 4
3 3
4 2
5 1

样例 1 输出

1.000000
0.600000

子任务

$1\leq R\leq N\leq 10^3$,$a_i,d_i$ 均为正整数,数据组数不超过 $50$ 组,所有攻击力和防御力都是正整数。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.