A942 | Talent Show--Gold
来源USACO
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Farmer John is bringing his $N$ cows, conveniently numbered $1 \ldots N$, to
the county fair, to compete in the annual bovine talent show! His $i$th cow
has a weight $w_i$ and talent level $t_i$, both integers.
Upon arrival, Farmer John is quite surprised by the new rules for this year's
talent show:
(i) A group of cows of total weight at least $W$ must be entered into the show
(in order to ensure strong teams of cows are competing, not just strong
individuals), and
(ii) The group with the largest ratio of total talent to total weight shall
win.
FJ observes that all of his cows together have weight at least $W$, so he
should be able to enter a team satisfying (i). Help him determine the optimal
ratio of talent to weight he can achieve for any such team.
the county fair, to compete in the annual bovine talent show! His $i$th cow
has a weight $w_i$ and talent level $t_i$, both integers.
Upon arrival, Farmer John is quite surprised by the new rules for this year's
talent show:
(i) A group of cows of total weight at least $W$ must be entered into the show
(in order to ensure strong teams of cows are competing, not just strong
individuals), and
(ii) The group with the largest ratio of total talent to total weight shall
win.
FJ observes that all of his cows together have weight at least $W$, so he
should be able to enter a team satisfying (i). Help him determine the optimal
ratio of talent to weight he can achieve for any such team.
输入格式
The first line of input contains $N$ ($1 \leq N \leq 250$) and $W$ ($1 \leq W
\leq 1000$). The next $N$ lines each describe a cow using two integers $w_i$
($1 \leq w_i \leq 10^6$) and $t_i$ ($1 \leq t_i \leq 10^3$).
\leq 1000$). The next $N$ lines each describe a cow using two integers $w_i$
($1 \leq w_i \leq 10^6$) and $t_i$ ($1 \leq t_i \leq 10^3$).
输出格式
Please determine the largest possible ratio of total talent over total weight
Farmer John can achieve using a group of cows of total weight at least $W$. If
your answer is $A$, please print out the floor of $1000A$ in order to keep the
output integer-valued (the floor operation discards any fractional part by
rounding down to an integer, if the number in question is not already an
integer).
Farmer John can achieve using a group of cows of total weight at least $W$. If
your answer is $A$, please print out the floor of $1000A$ in order to keep the
output integer-valued (the floor operation discards any fractional part by
rounding down to an integer, if the number in question is not already an
integer).
输入输出样例
输入 #1
3 15 20 21 10 11 30 31
输出 #1
1066
In this example, the best talent-to-weight ratio overall would be to use just
the single cow with talent 11 and weight 10, but since we need at least 15
units of weight, the optimal solution ends up being to use this cow plus the
cow with talent 21 and weight 20. This gives a talent-to-weight ratio of
(11+21)/(10+20) = 32/30 = 1.0666666..., which when multiplied by 1000 and
floored gives 1066.
the single cow with talent 11 and weight 10, but since we need at least 15
units of weight, the optimal solution ends up being to use this cow plus the
cow with talent 21 and weight 20. This gives a talent-to-weight ratio of
(11+21)/(10+20) = 32/30 = 1.0666666..., which when multiplied by 1000 and
floored gives 1066.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted