結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー 6v86v8
提出日時 2014-12-04 23:24:00
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 991 bytes
コンパイル時間 2,137 ms
コンパイル使用メモリ 74,100 KB
実行使用メモリ 143,740 KB
最終ジャッジ日時 2023-09-02 07:54:02
合計ジャッジ時間 15,038 ms
ジャッジサーバーID
(参考情報)
judge14 / judge16
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;



public class Main {
int n,m,mod;
int[] b;
	public static void main(String[] args){	
		new Main().ans();
	}
	int sum=0;
	private void ans() {
		Scanner sc = new Scanner(System.in);
		n =sc.nextInt();
		b= new int[n];
		for(int i=0;i<n;i++) {
			b[i] =sc.nextInt();
			sum += b[i];
		}
		Arrays.sort(b);//昇順ソート
		int t = sc.nextInt();
		for(int i=0;i<t;i++) answer(sc.nextDouble());
	}
	private void answer(double i) {
		int anstable[] = new int[b.length];
		double kari = (double)(sum/i);
		
				int t = 0;
				double[] mynex =  new double[b.length];
				for(int j = 0; j<b.length;j++){
					anstable[j] = (int)(b[j]/kari);
					mynex[j] = b[j]/(double)(anstable[j]+1);
					t+=anstable[j];
				}
				if(t >=i){
					System.out.println(kari);
				}else{
				Arrays.sort(b);
				System.out.println(mynex[(int) (b.length - 1-(i-t))]);
				}
			
	}
	
}
0