結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー fjafjafjafjafjafja
提出日時 2017-09-20 21:30:13
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 601 bytes
コンパイル時間 3,010 ms
コンパイル使用メモリ 75,284 KB
実行使用メモリ 69,628 KB
最終ジャッジ日時 2024-04-25 21:21:50
合計ジャッジ時間 25,635 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 824 ms
68,976 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 926 ms
69,564 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 983 ms
68,928 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 806 ms
69,364 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 854 ms
69,020 KB
testcase_16 AC 962 ms
69,628 KB
testcase_17 AC 996 ms
69,208 KB
testcase_18 AC 915 ms
69,532 KB
testcase_19 AC 997 ms
68,760 KB
testcase_20 AC 1,028 ms
68,796 KB
testcase_21 AC 865 ms
68,672 KB
testcase_22 AC 885 ms
69,496 KB
testcase_23 AC 791 ms
69,224 KB
testcase_24 AC 123 ms
54,024 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 194 ms
54,932 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class N067
{
	static double max=Integer.MAX_VALUE,min=Math.pow(10, -9),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];
		for(int i=0;i<n;i++)
		{
			l[i]=sc.nextInt();
		}
		k=sc.nextInt();

		double av=0;
		for(int i=0;i<100;i++)
		{
			av=(max+min)/2;
			int cnt=0;
			for(int j=0;j<n;j++)
			{
				cnt+=(int)(l[j]/av);
				if(cnt>=k)
				{break;}
			}

			if(cnt>=k)
			{
				min=av;
			}
			else
			{
				max=av;
			}
		}

		System.out.printf("%.8f",av);
	}
}
0