結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー 6v86v8
提出日時 2014-12-04 22:56:31
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 946 bytes
コンパイル時間 4,884 ms
コンパイル使用メモリ 79,616 KB
実行使用メモリ 73,748 KB
最終ジャッジ日時 2023-09-02 07:52:57
合計ジャッジ時間 15,513 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 next;
		double kari = (double)(sum/i);
		
			while(true){
				int t = 0;
				next = 0;
				for(int j = 0; j<b.length;j++){
					anstable[j] = (int)(b[j]/kari);
					next = Math.max(next, b[j]/(double)(anstable[j]+1));
					t+=anstable[j];
				}
				if(t >=i){
					System.out.println(kari);
					return;
				}
				kari =next;
			}	
	}
	
}
0