結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー GrenacheGrenache
提出日時 2016-05-18 19:46:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 467 ms / 5,000 ms
コード長 1,771 bytes
コンパイル時間 3,885 ms
コンパイル使用メモリ 78,988 KB
実行使用メモリ 71,812 KB
最終ジャッジ日時 2024-04-25 23:42:41
合計ジャッジ時間 17,407 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 467 ms
69,928 KB
testcase_01 AC 127 ms
54,100 KB
testcase_02 AC 312 ms
62,184 KB
testcase_03 AC 451 ms
67,120 KB
testcase_04 AC 428 ms
67,000 KB
testcase_05 AC 438 ms
67,424 KB
testcase_06 AC 427 ms
66,416 KB
testcase_07 AC 456 ms
71,800 KB
testcase_08 AC 451 ms
71,428 KB
testcase_09 AC 455 ms
71,536 KB
testcase_10 AC 432 ms
66,216 KB
testcase_11 AC 441 ms
66,948 KB
testcase_12 AC 409 ms
66,028 KB
testcase_13 AC 435 ms
71,480 KB
testcase_14 AC 446 ms
71,684 KB
testcase_15 AC 460 ms
67,412 KB
testcase_16 AC 427 ms
67,016 KB
testcase_17 AC 454 ms
67,252 KB
testcase_18 AC 433 ms
67,300 KB
testcase_19 AC 456 ms
71,608 KB
testcase_20 AC 457 ms
71,812 KB
testcase_21 AC 452 ms
71,664 KB
testcase_22 AC 441 ms
66,120 KB
testcase_23 AC 430 ms
66,108 KB
testcase_24 AC 125 ms
54,284 KB
testcase_25 AC 164 ms
54,512 KB
testcase_26 AC 144 ms
54,060 KB
testcase_27 AC 140 ms
54,140 KB
testcase_28 AC 276 ms
60,200 KB
testcase_29 AC 223 ms
56,548 KB
testcase_30 AC 159 ms
54,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder67 {

    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Printer pr = new Printer(System.out);

		int n = sc.nextInt();

		int[] l = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}

		long k = sc.nextLong();

		double ll = 0;
		double rr = 1_000_000_000;
		for (int i = 0; i < 100; i++) {
			double mid = ll + (rr - ll) / 2;

			if (isOK(mid, l, k)) {
				ll = mid;
			} else {
				rr = mid;
			}
		}

		pr.printf("%.10f\n", rr);

		pr.close();
		sc.close();
    }

	private static boolean isOK(double mid, int[] l, long k) {
		long cnt = 0;
		for (int e : l) {
			cnt += (long)(e / mid);
		}

		return cnt >= k;
	}

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
					it = Arrays.asList(br.readLine().split(" ")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}

		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0