結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー fjafjafjafjafjafja
提出日時 2017-09-20 21:20:07
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 832 bytes
コンパイル時間 3,101 ms
コンパイル使用メモリ 74,504 KB
実行使用メモリ 67,092 KB
最終ジャッジ日時 2023-08-08 03:24:29
合計ジャッジ時間 23,435 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 WA -
testcase_07 RE -
testcase_08 RE -
testcase_09 WA -
testcase_10 RE -
testcase_11 RE -
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 RE -
testcase_26 RE -
testcase_27 WA -
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];
		max=0;min=0;

		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