Tinder

Time limit: 0.15s Memory limit: 32MB Input: Output:

Alex wants to get a girlfriend. He discovered a dating app similar to Tinder. The app shows Alex NN different girls. He can swipe left or right on their photo. If he swipes right on a photo of a certain girl and she swipes right on his, then they match and can start chatting in the app.

Because he did not purchase the pro version, Alex has a limited number of right swipes. The app estimates for each girl the probability that she will swipe right on Alex. Moreover, the app will decrease the number of available swipes by a different value depending on the girl Alex swipes right on.

Help Alex find out what is the maximum expected number of matches he can get.

Input data

The first line of the input contains the values NN and XX, representing the number of girls shown to Alex and the maximum number of right swipes.

The following NN lines will contain data about the girls.

The ithi^{th} line will contain values pip_i and qiq_i, representing the probability that the ithi^{th} girl will swipe right on Alex and the value subtracted from the total number of available swipes if Alex swipes right on the ithi^{th} girl. Every pip_i value will be an integer between 00 and 100100, representing the probability as percentage.

Output data

The output will contain an integer that represents the maximum expected number of matches as a percentage.

Constraints and clarifications

  • 1N5 0001 \leq N \leq 5 \ 000
  • 1X,qi1041 \leq X, q_i \leq 10^4
  • For tests worth 1010 points, 1N201 \le N \le 20.
  • For tests worth extra 4040 points, 1NX1061 \le N \cdot X \le 10^6.

Example 1

stdin

6 3
70 1
54 3
20 1
9 1
20 2
33 1

stdout

123

Explanation

If Alex swipes right on the first, the third and the sixth girls then the expected number of matches he will get is equal to 1701 \cdot 70 + 1201 \cdot 20 + 1331 \cdot 33 = 123123. It turns out that this is the best he can do.

Log in or sign up to be able to send submissions!