結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー tentententen
提出日時 2023-06-12 18:04:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,780 ms / 5,000 ms
コード長 2,101 bytes
コンパイル時間 2,598 ms
コンパイル使用メモリ 88,140 KB
実行使用メモリ 65,068 KB
最終ジャッジ日時 2023-09-02 12:25:19
合計ジャッジ時間 41,559 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 343 ms
65,068 KB
testcase_01 AC 49 ms
50,032 KB
testcase_02 AC 790 ms
57,776 KB
testcase_03 AC 1,309 ms
58,104 KB
testcase_04 AC 1,780 ms
58,272 KB
testcase_05 AC 1,780 ms
58,560 KB
testcase_06 AC 1,695 ms
58,508 KB
testcase_07 AC 1,740 ms
61,188 KB
testcase_08 AC 1,745 ms
62,112 KB
testcase_09 AC 1,778 ms
63,852 KB
testcase_10 AC 1,548 ms
57,752 KB
testcase_11 AC 1,619 ms
58,088 KB
testcase_12 AC 1,505 ms
58,132 KB
testcase_13 AC 1,626 ms
62,212 KB
testcase_14 AC 1,642 ms
61,492 KB
testcase_15 AC 1,495 ms
58,436 KB
testcase_16 AC 1,710 ms
58,140 KB
testcase_17 AC 1,689 ms
57,884 KB
testcase_18 AC 1,691 ms
58,112 KB
testcase_19 AC 1,754 ms
61,908 KB
testcase_20 AC 1,770 ms
63,772 KB
testcase_21 AC 1,337 ms
63,104 KB
testcase_22 AC 1,301 ms
58,396 KB
testcase_23 AC 1,275 ms
57,612 KB
testcase_24 AC 48 ms
49,848 KB
testcase_25 AC 123 ms
52,644 KB
testcase_26 AC 90 ms
52,092 KB
testcase_27 AC 106 ms
53,504 KB
testcase_28 AC 447 ms
57,124 KB
testcase_29 AC 269 ms
54,128 KB
testcase_30 AC 124 ms
52,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int[] values = new int[n];
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
        }
        long k = sc.nextLong();
        double left = 0;
        double right = Integer.MAX_VALUE / 2;
        for (int i = 0; i < 1000; i++) {
            double m = (left + right) / 2;
            long count = 0;
            for (int j = 0; j < n && count < k; j++) {
                count += (long)(values[j] / m);
            }
            if (count >= k) {
                left = m;
            } else {
                right = m;
            }
        }
        System.out.println(new java.math.BigDecimal(left).toPlainString());
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0