結果
問題 |
No.67 よくある棒を切る問題 (1)
|
ユーザー |
|
提出日時 | 2018-02-06 14:47:52 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 630 bytes |
コンパイル時間 | 2,380 ms |
コンパイル使用メモリ | 77,124 KB |
実行使用メモリ | 70,212 KB |
最終ジャッジ日時 | 2025-03-03 11:08:53 |
合計ジャッジ時間 | 26,567 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 RE * 16 |
ソースコード
import java.util.*; import java.io.*; public class Main{ static int N; static int[] l; static int K; public static void main(String[] args) { Scanner sc = new Scanner(System.in); N = sc.nextInt(); l = new int[N]; for(int i=0; i<N; i++){ l[i] = sc.nextInt(); } K = sc.nextInt(); double lb = 0, ub = 1e12; for(int cnt = 0; cnt < 100; cnt++) { // while (ub - lb > 1) double mid = (lb + ub) / 2; if (mid < 1e-10) { lb = mid; continue; } int sum = 0; for(int i=0; i<N; i++){ sum += l[i] / mid; } if (sum >= K) lb = mid; else ub = mid; } System.out.println(lb); } }