結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー |
![]() |
提出日時 | 2017-09-20 20:44:31 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 959 bytes |
コンパイル時間 | 4,849 ms |
コンパイル使用メモリ | 81,220 KB |
実行使用メモリ | 79,024 KB |
最終ジャッジ日時 | 2025-03-03 10:53:35 |
合計ジャッジ時間 | 24,101 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 RE * 11 TLE * 1 -- * 13 |
ソースコード
import java.util.Scanner; public class N067 { static double max=0,min=Math.pow(10, -9),ans,k; static int n; static int[] l; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n=sc.nextInt(); l=new int[n]; max=0;min=0; for(int i=0;i<n;i++) { l[i]=sc.nextInt(); max=(l[i]>max)?l[i]:max; } k=sc.nextInt(); if(isok(max)) { System.out.println(max); } else { nibun(min,max); System.out.printf("%.8f",ans); } } static void nibun(double min,double max) { double av=(max+min)/2; double dif=max-min; if(dif<Math.pow(10, -8)) { ans=av; return; } else { if(isok(av)) { nibun(av,max); } else { nibun(min,av); } } } static boolean isok(double a) { int cnt=0; int end=0; for(int i=0;end==0&&i<n;i++) { cnt+=(int)(l[i]/a); if(cnt>=k) {end=1;} } if(end==1) { return true; } else { return false; } } }