아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Let’s Win the Election

시간 제한1.6초메모리 제한1024 MB

요약
각 주에서 연설 시간이 기준에 도달하면 표를 얻고 협력자를 확보하며, K표를 얻는 데 필요한 최소 연설 시간을 구한다.
난이도

보통10점 중 7점

유형
그리디, 이분 탐색, 정렬
정답자
아직 제출이 없습니다

문제

Republic of JOI consists of NN states, numbered from 11 to NN. 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 ii (1≤i≤N1 ≤ i ≤ N) reaches A_iA\_i hours, she will get the vote of State ii.
  • If the total time of speech in State ii (1≤i≤N1 ≤ i ≤ N) reaches B_iB\_i hours, she will get a collaborator from State ii. 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 ii. In this case, B_i=−1B\_i = -1. Otherwise, it is guaranteed that B_i≥A_iB\_i ≥ A\_i holds.

A collaborator from State ii (1≤i≤N1 ≤ i ≤ N) may deliver a speech outside State ii. 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 xx hours, the total time of speech in the state will be increased by 2x2x 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 KK 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 KK 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 KK votes. Your solution will be judged correct if the absolute value of the difference from correct answer is less than or equal to 0.010.01. 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 00 and 99. 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.

제한

  • 1≤N≤5001 ≤ N ≤ 500.
  • 1≤K≤N1 ≤ K ≤ N.
  • 1≤A_i≤1,0001 ≤ A\_i ≤ 1\\,000 (1≤i≤N1 ≤ i ≤ N).
  • A_i≤B_i≤1,000A\_i ≤ B\_i ≤ 1\\,000 or B_i=−1B\_i = -1 (1≤i≤N1 ≤ i ≤ N).

예제5

  1. 예제 1

    입력
    3
    3
    1 5
    2 3
    4 5
    
    예상 출력
    5.500000000000000
    
  2. 예제 2

    입력
    7
    4
    4 -1
    11 -1
    6 -1
    12 -1
    36 -1
    11 -1
    20 -1
    
    예상 출력
    32.000000000000000
    
  3. 예제 3

    입력
    5
    3
    4 -1
    5 -1
    6 -1
    7 7
    8 8
    
    예상 출력
    11.500000000000000
    
  4. 예제 4

    입력
    7
    5
    28 36
    11 57
    20 35
    19 27
    31 33
    25 56
    38 51
    
    예상 출력
    62.166666666666664
    
  5. 예제 5

    입력
    20
    14
    106 277
    175 217
    170 227
    164 245
    118 254
    139 261
    142 270
    185 200
    162 241
    153 239
    128 264
    103 299
    147 248
    158 236
    160 232
    183 205
    194 197
    135 260
    153 234
    128 260
    
    예상 출력
    644.203571428571422