結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー | t8m8⛄️ |
提出日時 | 2015-12-05 18:19:19 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 1,052 ms / 5,000 ms |
コード長 | 1,024 bytes |
コンパイル時間 | 3,821 ms |
コンパイル使用メモリ | 80,760 KB |
実行使用メモリ | 58,848 KB |
最終ジャッジ日時 | 2024-11-08 11:43:09 |
合計ジャッジ時間 | 30,947 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
ソースコード
import java.util.*; import java.io.*; import java.awt.geom.*; import java.math.*; public class No0067 { static final Scanner in = new Scanner(System.in); static final PrintWriter out = new PrintWriter(System.out,false); static void solve() { int n = in.nextInt(); int[] l = new int[n]; int max = 0; for (int i=0; i<n; i++) { l[i] = in.nextInt(); max = Math.max(max, l[i]); } long k = in.nextLong(); double lb = 0, ub = max; for (int i=0; i<100; i++) { double m = (lb + ub)/2; if (cnt(l,m) >= k) lb = m; else ub = m; } out.printf("%.10f\n",ub); } static long cnt(int[] l, double m) { long res = 0; for (int i=0; i<l.length; i++) { res += (long)(l[i]/m); } return res; } public static void main(String[] args) { long start = System.currentTimeMillis(); solve(); out.flush(); long end = System.currentTimeMillis(); //trace(end-start + "ms"); in.close(); out.close(); } static void trace(Object... o) { System.out.println(Arrays.deepToString(o));} }