結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-12-05 18:14:11
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,019 bytes
コンパイル時間 3,275 ms
コンパイル使用メモリ 76,420 KB
実行使用メモリ 66,668 KB
最終ジャッジ日時 2023-10-12 15:46:52
合計ジャッジ時間 25,930 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 836 ms
64,472 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 756 ms
64,928 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 811 ms
64,988 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 806 ms
64,804 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 788 ms
65,040 KB
testcase_16 AC 844 ms
65,440 KB
testcase_17 AC 727 ms
64,984 KB
testcase_18 AC 746 ms
65,004 KB
testcase_19 AC 809 ms
64,736 KB
testcase_20 AC 811 ms
64,876 KB
testcase_21 AC 832 ms
65,088 KB
testcase_22 AC 716 ms
65,192 KB
testcase_23 AC 724 ms
64,820 KB
testcase_24 AC 122 ms
55,908 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 197 ms
56,840 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class No0067 {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int n = in.nextInt();
		int[] l = new int[n];
		int max = 0;
		for (int i=0; i<n; i++) {
			l[i] = in.nextInt();
			max = Math.max(max, l[i]);
		}
		int k = in.nextInt();

		double lb = 0, ub = max;
		for (int i=0; i<100; i++) {
			double m = (lb + ub)/2;
			if (cnt(l,m) >= k) lb = m;
			else ub = m;
		}

		out.printf("%.10f\n",ub);
	}

	static int cnt(int[] l, double m) {
		int res = 0;
		for (int i=0; i<l.length; i++) {
			res += (int)(l[i]/m);
		}
		return res;
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}
0