結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー tentententen
提出日時 2021-11-10 10:51:50
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,776 ms / 5,000 ms
コード長 1,625 bytes
コンパイル時間 2,569 ms
コンパイル使用メモリ 78,400 KB
実行使用メモリ 63,632 KB
最終ジャッジ日時 2024-04-26 01:22:07
合計ジャッジ時間 41,036 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 344 ms
63,632 KB
testcase_01 AC 58 ms
50,940 KB
testcase_02 AC 802 ms
57,756 KB
testcase_03 AC 1,319 ms
59,480 KB
testcase_04 AC 1,733 ms
58,620 KB
testcase_05 AC 1,727 ms
58,616 KB
testcase_06 AC 1,735 ms
58,684 KB
testcase_07 AC 1,750 ms
60,940 KB
testcase_08 AC 1,739 ms
61,180 KB
testcase_09 AC 1,742 ms
61,308 KB
testcase_10 AC 1,587 ms
58,536 KB
testcase_11 AC 1,654 ms
58,432 KB
testcase_12 AC 1,584 ms
59,932 KB
testcase_13 AC 1,627 ms
61,312 KB
testcase_14 AC 1,677 ms
60,988 KB
testcase_15 AC 1,523 ms
59,376 KB
testcase_16 AC 1,757 ms
58,400 KB
testcase_17 AC 1,776 ms
59,796 KB
testcase_18 AC 1,603 ms
59,824 KB
testcase_19 AC 1,740 ms
61,184 KB
testcase_20 AC 1,725 ms
61,320 KB
testcase_21 AC 1,306 ms
61,132 KB
testcase_22 AC 1,335 ms
58,304 KB
testcase_23 AC 1,317 ms
58,456 KB
testcase_24 AC 60 ms
50,696 KB
testcase_25 AC 137 ms
52,724 KB
testcase_26 AC 125 ms
53,592 KB
testcase_27 AC 91 ms
52,568 KB
testcase_28 AC 475 ms
57,332 KB
testcase_29 AC 290 ms
53,956 KB
testcase_30 AC 137 ms
52,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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 = 1.0 / k;
        double right = Integer.MAX_VALUE;
        for (int i = 0; i < 1000; i++) {
            long sum = 0;
            double m = (left + right) / 2;
            for (int j = 0; j < n && sum < k; j++) {
                sum += (long)(values[j] / m);
            }
            if (sum >= k) {
                left = m;
            } else {
                right = m;
            }
        }
        System.out.println(new java.math.BigDecimal(left).toPlainString());
    }
    
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    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 String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0