結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー | youthfuldays072 |
提出日時 | 2018-06-16 18:08:09 |
言語 | Java21 (openjdk 21) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,073 bytes |
コンパイル時間 | 2,169 ms |
コンパイル使用メモリ | 73,680 KB |
実行使用メモリ | 68,852 KB |
最終ジャッジ日時 | 2023-09-13 06:12:14 |
合計ジャッジ時間 | 24,064 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 887 ms
64,844 KB |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | AC | 838 ms
66,936 KB |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | AC | 875 ms
64,740 KB |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | AC | 819 ms
64,764 KB |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | AC | 880 ms
64,820 KB |
testcase_16 | AC | 852 ms
66,816 KB |
testcase_17 | AC | 811 ms
66,496 KB |
testcase_18 | AC | 821 ms
66,908 KB |
testcase_19 | AC | 890 ms
67,384 KB |
testcase_20 | AC | 913 ms
66,880 KB |
testcase_21 | AC | 875 ms
67,404 KB |
testcase_22 | AC | 791 ms
66,836 KB |
testcase_23 | AC | 802 ms
66,680 KB |
testcase_24 | AC | 115 ms
56,152 KB |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | AC | 185 ms
54,112 KB |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
ソースコード
import java.util.Scanner; public class Main{ boolean[] isprime=new boolean[20010]; public static void main(String[] args) { Main main=new Main(); main.run(); } void run() { Scanner sc=new Scanner(System.in); int N=sc.nextInt(); double[] L=new double[N]; int maxlength=-1; for(int i=0;i<N;i++) { int buf=sc.nextInt(); L[i]=buf; if(maxlength<buf) { maxlength=buf; } } int K=sc.nextInt(); double l=0.0; double u=maxlength+1; double mid=0.0; for(int i=0;i<100;i++) { mid=(l+u)/2.0; if(judge(mid,L,K)) { l=mid; }else { u=mid; } } System.out.println(mid); } //ある幅で何本とれるか返す関数 public static int calc(double cutwidth,double[] L) { int count=0; for(int i=0;i<L.length;i++) { count+=(int)L[i]/cutwidth; } return count; } //ある幅でK本以上とれるかどうか判定する関数。 public static boolean judge(double cutwidth,double[] L,int K) { if(calc(cutwidth,L)>=K) { return true; }else { return false; } } }