結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー fjafjafjafjafjafja
提出日時 2017-09-20 21:21:54
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 816 bytes
コンパイル時間 3,097 ms
コンパイル使用メモリ 74,156 KB
実行使用メモリ 66,776 KB
最終ジャッジ日時 2023-08-08 03:25:18
合計ジャッジ時間 25,882 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 841 ms
64,892 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 957 ms
64,832 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 978 ms
64,828 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 890 ms
64,668 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 917 ms
64,820 KB
testcase_16 AC 965 ms
65,316 KB
testcase_17 AC 924 ms
64,828 KB
testcase_18 AC 902 ms
64,904 KB
testcase_19 AC 986 ms
64,564 KB
testcase_20 AC 961 ms
65,172 KB
testcase_21 AC 952 ms
64,816 KB
testcase_22 AC 838 ms
64,620 KB
testcase_23 AC 894 ms
65,164 KB
testcase_24 AC 122 ms
56,500 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 201 ms
56,832 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),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];
		for(int i=0;i<n;i++)
		{
			l[i]=sc.nextInt();
		}
		k=sc.nextInt();


		nibun(min,max);
		System.out.printf("%.8f",ans);


	}

	static void nibun(double min,double max)
	{
		double av=0;
		for(int i=0;i<100;i++)
		{
			av=(max+min)/2;
			if(isok(av))
			{
				min=av;
			}
			else
			{
				max=av;
			}
		}
		ans=av;
		return;
	}

	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;
		}
	}
}
0