結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー fjafjafjafjafjafja
提出日時 2017-09-20 21:11:42
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 912 bytes
コンパイル時間 3,434 ms
コンパイル使用メモリ 77,964 KB
実行使用メモリ 69,836 KB
最終ジャッジ日時 2024-04-25 21:19:34
合計ジャッジ時間 28,165 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 787 ms
69,144 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 1,185 ms
69,836 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 1,097 ms
69,220 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 1,025 ms
69,252 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 1,049 ms
69,336 KB
testcase_16 AC 979 ms
58,788 KB
testcase_17 AC 1,152 ms
59,000 KB
testcase_18 AC 1,149 ms
69,668 KB
testcase_19 AC 1,126 ms
57,896 KB
testcase_20 AC 1,078 ms
66,796 KB
testcase_21 AC 1,053 ms
58,508 KB
testcase_22 AC 699 ms
53,480 KB
testcase_23 AC 986 ms
59,180 KB
testcase_24 AC 124 ms
41,116 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 192 ms
42,936 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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=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