import java.io.*; import java.util.*; public class yesorno { public static void main(String[] args) { try { new yesorno(); } catch (Exception e) { e.printStackTrace(); } } public yesorno() throws Exception { BufferedReader br = new BufferedReader(new FileReader(new File("yesorno.in"))); int dataSets = Integer.parseInt(br.readLine()); for (int dataSet = 0; dataSet < dataSets; dataSet++) { System.out.println("Data Set " + (dataSet + 1) + ":"); //get the l r n line StringTokenizer tok = new StringTokenizer(br.readLine()); int min = Integer.parseInt(tok.nextToken()); int max = Integer.parseInt(tok.nextToken()); int n = Integer.parseInt(tok.nextToken()); double question[] = new double[n]; for (int q = 0; q < n; q++) { question[q] = Float.parseFloat(br.readLine()); } // sorts low to high Arrays.sort(question); int yesUsed = 0; int yesRemaining = max; double right = 0; for (int i = question.length - 1; i >= 0; i--) { if(yesUsed < min || (question[i] > 0.5 && yesRemaining > 0)) { yesUsed++; yesRemaining--; right += question[i]; } else { right += 1 - question[i]; } } System.out.println((new java.text.DecimalFormat("#.##")).format(right)); } } }