#P4085. [USACO17DEC] Haybale Feast G
[USACO17DEC] Haybale Feast G
题目描述
Farmer John is preparing a delicious meal for his cows! In his barn, he has haybales (). The th haybale has a certain flavor () and a certain spiciness ().
The meal will consist of a single course, being a contiguous interval containing one or more consecutive haybales (Farmer John cannot change the order of the haybales). The total flavor of the meal is the sum of the flavors in the interval. The spiciness of the meal is the maximum spiciness of all haybales in the interval.
Farmer John would like to determine the minimum spiciness his single-course meal could achieve, given that it must have a total flavor of at least ().
输入格式
The first line contains the integers and , the number of haybales and the minimum total flavor the meal must have, respectively. The next lines describe the haybales with two integers per line, first the flavor and then the spiciness .
输出格式
Please output the minimum spiciness in a single course meal that satisfies the minimum flavor requirement. There will always be at least one single-course meal that satisfies the flavor requirement.
题目大意
农夫约翰正在为他的奶牛准备一顿美味的晚餐!在他的谷仓里,他有 个干草捆 。第 个干草捆有一定的风味 和一定的辣度 。
这顿饭将由一道菜组成,是一个连续的区间,包含一个或多个连续的干草捆(农夫约翰不能改变干草捆的顺序)。这顿饭的总体的风味是这段区间里风味的总和。这顿饭的总体辣度是区间中所有草包的最大辣度。
农夫约翰想确定他的这道菜所能达到的最小辣度,但是这道菜的总风味必须至少为 。
输入格式
第一行包含两个整数 和 ,分别是干草包的数量和这顿饭必须有的最小风味之和。
接下来的 行,每行两个整数描述这 个草包,首先是风味 ,然后是辣度 。
输出格式
请输出这道菜中在满足最低风味时的最低辣度。保证至少有一顿单道菜的饭能满足风味的要求。
5 10
4 10
6 15
3 5
4 9
3 6
9