結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー | jp_ste |
提出日時 | 2016-06-08 19:17:41 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 286 ms / 5,000 ms |
コード長 | 3,438 bytes |
コンパイル時間 | 2,462 ms |
コンパイル使用メモリ | 77,752 KB |
実行使用メモリ | 44,024 KB |
最終ジャッジ日時 | 2024-11-08 11:52:35 |
合計ジャッジ時間 | 11,240 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 251 ms
42,400 KB |
testcase_01 | AC | 124 ms
41,172 KB |
testcase_02 | AC | 206 ms
41,680 KB |
testcase_03 | AC | 269 ms
43,728 KB |
testcase_04 | AC | 265 ms
43,964 KB |
testcase_05 | AC | 236 ms
42,120 KB |
testcase_06 | AC | 236 ms
42,232 KB |
testcase_07 | AC | 248 ms
42,528 KB |
testcase_08 | AC | 250 ms
42,292 KB |
testcase_09 | AC | 246 ms
42,292 KB |
testcase_10 | AC | 236 ms
42,244 KB |
testcase_11 | AC | 246 ms
42,324 KB |
testcase_12 | AC | 235 ms
42,212 KB |
testcase_13 | AC | 276 ms
44,024 KB |
testcase_14 | AC | 285 ms
43,976 KB |
testcase_15 | AC | 271 ms
43,748 KB |
testcase_16 | AC | 240 ms
42,416 KB |
testcase_17 | AC | 242 ms
42,116 KB |
testcase_18 | AC | 241 ms
42,092 KB |
testcase_19 | AC | 286 ms
42,468 KB |
testcase_20 | AC | 268 ms
43,860 KB |
testcase_21 | AC | 252 ms
42,408 KB |
testcase_22 | AC | 277 ms
43,804 KB |
testcase_23 | AC | 236 ms
42,252 KB |
testcase_24 | AC | 124 ms
41,196 KB |
testcase_25 | AC | 147 ms
41,324 KB |
testcase_26 | AC | 134 ms
41,132 KB |
testcase_27 | AC | 131 ms
40,972 KB |
testcase_28 | AC | 183 ms
41,668 KB |
testcase_29 | AC | 176 ms
41,488 KB |
testcase_30 | AC | 148 ms
41,100 KB |
ソースコード
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; public class Main { static FastScanner scan = new FastScanner(); static PrintWriter out = new PrintWriter(System.out); static int n; static int[] a; static long k; public static void main(String[] args) { n = scan.nextInt(); a = new int[n]; for(int i=0; i<n; i++) { a[i] = scan.nextInt(); } k = scan.nextLong(); double l = 0; double r = Integer.MAX_VALUE; for(int i=0; i<100; i++) { double m = (l+r)/2; if(comp(m)) { l = m; } else { r = m; } } System.out.printf("%.10f\n", l); } static boolean comp(double x) { long count = 0; for(int i=0; i<a.length; i++) { count += (long)(a[i] / x); } return count >= k; } static 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 static 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 int nextInt() { return (int)nextLong(); } 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(); } } } }