Problem I
Installing Apps
Each app that Sandra installs has a download size $d$ and a storage size $s$. To download the app, Sandra’s phone must have at least $d$ megabytes of free disk space. After the app has been installed, it then uses $s$ megabytes of disk space on the phone. The download size may be smaller than the storage size (e.g., if the app data is heavily compressed) or larger than the storage size (e.g., if the download contains material that might not get used such as translations to different languages). The installer is very efficient and can transform the downloaded package to an installed app without using any extra disk space. Thus, to install an app, the phone must have at least $\max (d, s)$ megabytes of free disk space.
Sandra quickly realised that she may have run out of space just because she installed apps in the wrong order. Thus, she decided to give the installation another try. She uninstalled all apps, and will now choose an installation order that lets her install the largest number of apps from the list. Sandra may not install any app more than once.
Help her determine what apps on the list she should install, and in what order.
Input
The input consists of:
-
One line with two integers $n$, $c$ ($1 \le n \le 500, 1 \le c \le 10\, 000$), the number of available apps and the available disk space of the phone in megabytes.
-
$n$ lines, each with two integers $d, s$ ($1 \le d, s \le 10\, 000$), the download size and storage size of an app, in megabytes.
Output
Output one line with the maximum number of apps that can be installed. Then output one line listing the numbers of those apps, in the order that Sandra should install them. In the case that no apps can be installed, this line can be omitted.
The apps are numbered from $1$ to $n$, in the order they are given in the input. If there are multiple optimal solutions, output any one of them.
Sample Input 1 | Sample Output 1 |
---|---|
2 100 99 1 1 99 |
2 1 2 |
Sample Input 2 | Sample Output 2 |
---|---|
2 100 500 1 1 500 |
0 |