Let’s Win the Election
시간 제한1.6초메모리 제한1024 MB
각 주에서 연설 시간이 기준에 도달하면 표를 얻고 협력자를 확보하며, K표를 얻는 데 필요한 최소 연설 시간을 구한다.
문제
Republic of JOI consists of states, numbered from to . In 2022, the presidential election will be held in Republic of JOI. The election will be held in each state. The winner of the election in a state will get the vote of the state.
Rie will run for the president. She is planning to win the election. Her plan is to deliver a speech in order to increase the degree of reliability. After she delivers a speech, the following will happen.
- If the total time of speech in State () reaches hours, she will get the vote of State .
- If the total time of speech in State () reaches hours, she will get a collaborator from State . After that, the collaborator will be able to deliver a speech in order to increase the total time of speech.
- It may be the case that Rie cannot get any collaborator from State . In this case, . Otherwise, it is guaranteed that holds.
A collaborator from State () may deliver a speech outside State . More than one person may deliver a speech in the same state simultaneously. For example, if two people deliver a speech in a state for hours, the total time of speech in the state will be increased by hours. The time of speech needs not be an integer. We will ignore the travel time between states.
Since the election day is coming soon, Rie would like to get votes as soon as possible.
Given the number of the states and information of each state, write a program which calculate the minimum number of hours required to get votes.
입력
Read the following data from the standard input. Given values are all integers.
\begin{align\*} & N \\\ & K \\\ & A\_1 \\, B\_1 \\\ & A\_2 \\, B\_2 \\\ & \vdots \\\ & A\_N \\, B\_N \end{align\*}
출력
Write one line to the standard output. The output should contain the minimum number of hours required to get votes. Your solution will be judged correct if the absolute value of the difference from correct answer is less than or equal to . The output should be written in one of the following formats.
- An integer. (Example:
123,0,-2022) - A sequence consisting of an integer, a period, and a sequence of digits between and . It should not contain separating characters. There is no restriction on the number of digits after the decimal point. (Example:
123.4,-123.00,0.00288)
The output should not be written in exponential notation. For example, 1.23456e+05 and 1.23456e5 are not allowed.
제한
- .
- .
- ().
- or ().