結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー |
|
提出日時 | 2016-05-18 19:46:30 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 455 ms / 5,000 ms |
コード長 | 1,771 bytes |
コンパイル時間 | 3,832 ms |
コンパイル使用メモリ | 81,404 KB |
実行使用メモリ | 78,144 KB |
最終ジャッジ日時 | 2025-03-03 10:34:49 |
合計ジャッジ時間 | 16,675 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
ソースコード
import java.io.*; import java.util.*; public class Main_yukicoder67 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); int n = sc.nextInt(); int[] l = new int[n]; for (int i = 0; i < n; i++) { l[i] = sc.nextInt(); } long k = sc.nextLong(); double ll = 0; double rr = 1_000_000_000; for (int i = 0; i < 100; i++) { double mid = ll + (rr - ll) / 2; if (isOK(mid, l, k)) { ll = mid; } else { rr = mid; } } pr.printf("%.10f\n", rr); pr.close(); sc.close(); } private static boolean isOK(double mid, int[] l, long k) { long cnt = 0; for (int e : l) { cnt += (long)(e / mid); } return cnt >= k; } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator<String> it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }