結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー | 37zigen |
提出日時 | 2018-05-30 19:04:00 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,930 ms / 5,000 ms |
コード長 | 2,518 bytes |
コンパイル時間 | 3,831 ms |
コンパイル使用メモリ | 78,312 KB |
実行使用メモリ | 42,148 KB |
最終ジャッジ日時 | 2024-11-08 12:42:51 |
合計ジャッジ時間 | 49,534 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,884 ms
40,868 KB |
testcase_01 | AC | 52 ms
36,596 KB |
testcase_02 | AC | 784 ms
39,324 KB |
testcase_03 | AC | 1,439 ms
41,928 KB |
testcase_04 | AC | 1,923 ms
40,612 KB |
testcase_05 | AC | 1,927 ms
40,340 KB |
testcase_06 | AC | 1,912 ms
40,616 KB |
testcase_07 | AC | 1,928 ms
40,464 KB |
testcase_08 | AC | 1,930 ms
40,800 KB |
testcase_09 | AC | 1,920 ms
40,732 KB |
testcase_10 | AC | 1,746 ms
40,652 KB |
testcase_11 | AC | 1,859 ms
40,816 KB |
testcase_12 | AC | 1,684 ms
40,372 KB |
testcase_13 | AC | 1,776 ms
40,576 KB |
testcase_14 | AC | 1,851 ms
40,636 KB |
testcase_15 | AC | 1,651 ms
40,432 KB |
testcase_16 | AC | 1,915 ms
42,148 KB |
testcase_17 | AC | 1,914 ms
42,096 KB |
testcase_18 | AC | 1,892 ms
40,772 KB |
testcase_19 | AC | 1,909 ms
40,900 KB |
testcase_20 | AC | 1,892 ms
40,612 KB |
testcase_21 | AC | 1,887 ms
40,728 KB |
testcase_22 | AC | 1,699 ms
40,640 KB |
testcase_23 | AC | 1,793 ms
40,624 KB |
testcase_24 | AC | 51 ms
36,860 KB |
testcase_25 | AC | 108 ms
37,760 KB |
testcase_26 | AC | 79 ms
37,864 KB |
testcase_27 | AC | 74 ms
37,776 KB |
testcase_28 | AC | 377 ms
38,468 KB |
testcase_29 | AC | 229 ms
38,360 KB |
testcase_30 | AC | 109 ms
38,040 KB |
ソースコード
import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.HashSet; import java.util.NoSuchElementException; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void run() { FastScanner sc = new FastScanner(); int N = sc.nextInt(); long[] L = new long[N]; for (int i = 0; i < N; ++i) { L[i] = sc.nextLong(); } long K = sc.nextLong(); double ok = 0, ng = Double.MAX_VALUE / 3; out: while (ng - ok > 1e-10 && (ng - ok) / ng > 1e-10) { double m = (ok + ng) / 2; long cur = 0; for (int i = 0; i < N; ++i) { cur += L[i] / m; if (cur >= K) { ok = m; continue out; } } ng = m; } System.out.println(ok); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; } else { ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } public boolean hasNext() { skipUnprintable(); return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { return (int) nextLong(); } } }