Julian gave the following programming problem to his students : given an array of elements, remove the elements with indices .
A common solution that his students submitted looked as follows:
for (int i = 0; i < m; ++i) { // Iterate over array K.
A.remove(K.get(i)); // Remove K[i]th element from A.
}
Julian would like to show that this solution is incorrect. To do this, he would like to determine which elements are actually removed by this algorithm for a given input. Could you help him out?
Input Specification
The first line of input contains a two integers , the number of elements in the array and the number of elements to remove. The next line of input contains integers , the indices to remove.
For 30 of 100 points, .
For 70 of 100 points, .
Output Specification
If at some point, the incorrect program would attempt an index that is out-of-bounds, output Out of bounds
. Otherwise, print the set of original indices removed by the incorrect solution in sorted order.
Sample Input 1
5 2
2 4
Sample Output 1
2 5
Sample Input 2
5 3
1 1 4
Sample Output 2
Out of bounds
Comments