import java.io.*; public class Quantiles { static int[] vals = new int[5000]; /// to hold input series static int[] quantiles; /// to hold quantiles static int n = 5000; /// number of inputs static int d, k; /// d=n/k, k=quantiles static int cmpct; /// comparison counter public static void main(String argv[]) throws IOException { /** Read from standard input one line at a time. Place each line into the array vals[] as an int. **/ BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); for (int r=0;rrank) { quantilesAbove = true; cmpct++; } } /** If we find that there are (ANY) desired quantile indexes in either partition around [rank], perform detSelect on the interval of that partition. **/ if (quantilesBelow) detSelect(start,rank); if (quantilesAbove) detSelect(rank+1,fin); /** Otherwise, this iteration will close without doing anything, and other iterations will fill in the quantiles array. **/ return; } public static int partition(int start, int fin) { /** In the partition function we will use the value located at the "middle" index of the interval. There is not expected to be a benefit from choosing that index, unless we are given already-sorted input. **/ int hold; int x=vals[(fin+start)/2]; int i=start; int j=fin-1; while (true) { while (vals[j]>x && j>start) { j--; cmpct++; } while (vals[i]