eolymp
bolt
Try our new interface for solving problems
Problems

Candies

Candies

Fuad loves to eat candies, and there is a big confectionery shop near their house. This shop has announced a new promotion. When paying in cash, they return the change to their customers in candies. One candy for each qapik. Of course, the number of candies they give cannot exceed $99$, because $100$ qapiks can be replaced with $1$ manat, and the shop always follows this principle. Fuad's grandmother gave him $s$ manats in cash and told him to buy a cake at the confectionery. The shop sells $n$ different cakes. The price of cake $i$ is $m_i$ manats and $q_i$ qapiks. Now Fuad is only concerned about which cake to buy to get as many candies as possible. He doesn't care whether the cake he buys is expensive or cheap. Find the maximum number of candies that Fuad can get. If Fuad doesn't have enough money to buy any cake, print $−1$. \InputFile The first line contains two integers $n$ and $s~(1 \le n, s \le 100)$. Each of the following $n$ lines contains two integers $m_i~(1 \le m_i \le 100)$ and $q_i~(0 \le q_i < 100)$. \OutputFile Print the maximum number of candies that Fuad can get from buying one cake, and $−1$ if he doesn't have enough money to buy any cake.
Time limit 1 second
Memory limit 128 MiB
Input example #1
4 50
20 80
15 90
30 40
60 0
Output example #1
60
Input example #2
4 10
20 80
15 90
30 40
60 0
Output example #2
-1
Source 2024, Azerbaijan, Republic Informatics Olympiad, Semifinals, 10 - 11 class, February 18