結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー takeya_okinotakeya_okino
提出日時 2019-08-01 20:47:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 2,038 ms / 5,000 ms
コード長 663 bytes
コンパイル時間 2,049 ms
コンパイル使用メモリ 74,184 KB
実行使用メモリ 67,548 KB
最終ジャッジ日時 2024-04-26 00:46:50
合計ジャッジ時間 50,986 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,827 ms
67,360 KB
testcase_01 AC 155 ms
54,440 KB
testcase_02 AC 1,276 ms
62,944 KB
testcase_03 AC 1,700 ms
65,160 KB
testcase_04 AC 2,038 ms
67,404 KB
testcase_05 AC 1,683 ms
67,412 KB
testcase_06 AC 1,839 ms
67,380 KB
testcase_07 AC 1,897 ms
67,328 KB
testcase_08 AC 1,805 ms
67,224 KB
testcase_09 AC 1,942 ms
67,356 KB
testcase_10 AC 1,978 ms
67,104 KB
testcase_11 AC 2,026 ms
67,400 KB
testcase_12 AC 1,796 ms
67,392 KB
testcase_13 AC 1,810 ms
67,404 KB
testcase_14 AC 1,988 ms
67,128 KB
testcase_15 AC 1,839 ms
67,356 KB
testcase_16 AC 1,905 ms
67,244 KB
testcase_17 AC 1,442 ms
67,260 KB
testcase_18 AC 1,831 ms
67,288 KB
testcase_19 AC 1,977 ms
67,548 KB
testcase_20 AC 1,933 ms
67,220 KB
testcase_21 AC 1,915 ms
67,084 KB
testcase_22 AC 1,777 ms
67,548 KB
testcase_23 AC 1,764 ms
67,196 KB
testcase_24 AC 140 ms
54,400 KB
testcase_25 AC 359 ms
63,488 KB
testcase_26 AC 293 ms
60,656 KB
testcase_27 AC 265 ms
59,712 KB
testcase_28 AC 947 ms
63,424 KB
testcase_29 AC 615 ms
62,440 KB
testcase_30 AC 371 ms
60,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double[] l = new double[n];
    for(int i = 0; i < n; i++) {
      l[i] = sc.nextDouble();
    }
    long k = sc.nextLong();
    double ans = 0;
    double left = 0;
    double right = 1000000001;
    for(int i = 0; i < 70; i++) {
      double med = (left + right) / 2;
      long t = 0;
      for(int j = 0; j < n; j++) {
        t += ((long)(l[j] / med));
      }
      if(t >= k) {
        ans = med;
        left = med;
      } else {
        right = med;
      }
    }
    System.out.println(ans);
  }
}
0