Submission #122788


Source Code Expand

Copy
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main {
	static int N;
	static int K;
	
	static List<Integer> list;
	
	public Main() {
		// TODO 自動生成されたコンストラクター・スタブ
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		read();
		
		solve();
	}
	
	private static double dfs(boolean[] bit){
		double max = 0;
		
		int num = 0;
		for(int i = 0; i<bit.length; i++){
			if(bit[i]){
				num++;
				max = (max + list.get(i))/2;
			}
		}
		if(num > K){
			return 0;
		}
		
		for(int i = 0; i<bit.length; i++){
			if(bit[i]){
				continue;
			}
			
			boolean[] tmpbit = bit.clone();
			tmpbit[i] = true;
			
			double tmpd = dfs(tmpbit);
			if(max < tmpd){
				max = tmpd;
			}
		}
		
		return max;
	}
	
	private static void solve() {
		Collections.sort(list);
		
		boolean[] bit = new boolean[N];

		System.out.format("%.6f", dfs(bit));
	}
	
	private static void read(){
		Scanner scan = new Scanner(new InputStreamReader(System.in));
	
		N = scan.nextInt();
		K = scan.nextInt();
		
		list = new ArrayList<Integer>();
		
		for(int i = 0; i < N; i++){
			list.add(scan.nextInt());
		}
		
	}
}

Submission Info

Submission Time
Task C - AtCoderプログラミング講座
User keitaro9ml
Language Java (OpenJDK 1.7.0)
Score 0
Code Size 1387 Byte
Status TLE
Exec Time 2056 ms
Memory 32332 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 10
TLE × 24
Set Name Test Cases
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 462 ms 23472 KB
00_sample_02.txt AC 477 ms 23600 KB
00_sample_03.txt AC 510 ms 30448 KB
00_sample_04.txt AC 1556 ms 32120 KB
test_01.txt AC 500 ms 23724 KB
test_02.txt TLE 2037 ms 32008 KB
test_03.txt TLE 2039 ms 31864 KB
test_04.txt AC 490 ms 25392 KB
test_05.txt TLE 2038 ms 31988 KB
test_06.txt TLE 2037 ms 32004 KB
test_07.txt AC 488 ms 25392 KB
test_08.txt TLE 2037 ms 31952 KB
test_09.txt TLE 2038 ms 31880 KB
test_10.txt AC 476 ms 25264 KB
test_11.txt TLE 2038 ms 32332 KB
test_12.txt TLE 2042 ms 32076 KB
test_13.txt TLE 2056 ms 32020 KB
test_14.txt TLE 2038 ms 31848 KB
test_15.txt TLE 2037 ms 31740 KB
test_16.txt TLE 2037 ms 32244 KB
test_17.txt TLE 2039 ms 32192 KB
test_18.txt TLE 2039 ms 31928 KB
test_19.txt TLE 2037 ms 31744 KB
test_20.txt TLE 2038 ms 32192 KB
test_21.txt AC 719 ms 31664 KB
test_22.txt TLE 2042 ms 32004 KB
test_23.txt TLE 2040 ms 32064 KB
test_24.txt TLE 2037 ms 32080 KB
test_25.txt TLE 2038 ms 31932 KB
test_26.txt TLE 2038 ms 32004 KB
test_27.txt TLE 2040 ms 32168 KB
test_28.txt AC 668 ms 31736 KB
test_29.txt TLE 2038 ms 31996 KB
test_30.txt TLE 2051 ms 31876 KB