A620.[USACO 2014 December Gold]Guard Mark

提高+/省选-

USACO

通过率:0%

时间限制:1.00s

内存限制:128MB

题目描述

Farmer John and his herd are playing frisbee. Bessie throws the
frisbee down the field, but it's going straight to Mark the field hand
on the other team! Mark has height H (1 <= H <= 1,000,000,000), but
there are N cows on Bessie's team gathered around Mark (2 <= N <= 20).
They can only catch the frisbee if they can stack up to be at least as
high as Mark. Each of the N cows has a height, weight, and strength.
A cow's strength indicates the maximum amount of total weight of the
cows that can be stacked above her.

Given these constraints, Bessie wants to know if it is possible for
her team to build a tall enough stack to catch the frisbee, and if so,
what is the maximum safety factor of such a stack. The safety factor
of a stack is the amount of weight that can be added to the top of the
stack without exceeding any cow's strength.

农夫约翰在和他的牛群在玩飞盘。贝茜把飞盘扔给身高为 HH1H1×1091 \le H \le 1 \times 10^9)的马克,有 NN 头牛聚集在马克周围(2N202 \le N \le 20)。它们的身高在大于等于马克时能抢到飞盘。每头牛都有自己的身高、体重和耐力值。一头奶牛的耐力值是指最大能承受的叠在它上方的牛的重量和。

考虑到这些条件,贝茜想知道是否有可能建立一个足够高的牛塔来捕捉飞盘,若可以,这种牛塔的最大安全系数是多少。一个牛塔的安全系数是指每头牛的耐力都可以承受的前提下能在牛塔上添加的最大重量。

输入格式

The first line of input contains N and H.

The next N lines of input each describe a cow, giving its height,
weight, and strength. All are positive integers at most 1 billion.

输入的第一行包含 NNHH

接下来的 NN 行每行输入三个整数,表示每头牛的高度,重量和耐力值,不超过 10910^9

输出格式

If Bessie's team can build a stack tall enough to catch the frisbee,
please output the maximum achievable safety factor for such a stack.
Otherwise output "Mark is too tall" (without the quotes).

能造出牛塔来接住飞盘,输出牛塔的最大安全系数。
否则,将输出“MarkistootallMark is too tall”(没有引号)。

输入输出样例

  • 输入#1

    4 10 
    9 4 1 
    3 3 5 
    5 5 10 
    4 4 5

    输出#1

    2
首页