I/S. 3. One can buy \(\displaystyle 1\le N\le 1000\) items in a shop. Your available money is \(\displaystyle 1\le P \le 10^9\).
Each item has a price \(\displaystyle A_i\), and a home delivery cost \(\displaystyle H_i\), so the total cost of item \(\displaystyle i\) is \(\displaystyle A_i+H_i\) (non-negative integers, \(\displaystyle A_i\) is even to simplify this exercise). We also have a coupon to halve the price of a selected item: if we use it with item \(\displaystyle i\), then its price would be \(\displaystyle A_i/2+H_i\). Determine the maximum number of items that can be bought if we are allowed to use only one coupon. Your program should read the values of \(\displaystyle N\) and \(\displaystyle P\) from the first line of the standard input, then the integers \(\displaystyle A_i\), \(\displaystyle H_i\) (separated by a space) from the following \(\displaystyle N\) lines. The first and only line of the standard output should contain the maximum number of items that can be purchased.
Explanation: it is possible to buy the first 4 items provided that the coupon is used with the third item.
Scoring and bounds. You can get 1 point for a brief and proper documentation clearly describing your solution. Nine further points can be obtained provided that your program solves any valid input within 1 second of running time.
The source code of your program without the .exe or any other auxiliary files generated by the compiler but with a short documentation-also describing which developer environment to use for compiling the source-should be submitted in a compressed file is3.zip.
Deadline expired on 10 December 2015.