結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー fjafjafjafjafjafja
提出日時 2017-09-20 21:21:54
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 816 bytes
コンパイル時間 3,651 ms
コンパイル使用メモリ 77,292 KB
実行使用メモリ 58,964 KB
最終ジャッジ日時 2024-11-08 09:18:15
合計ジャッジ時間 31,275 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15 RE * 16
権限があれば一括ダウンロードができます

ソースコード

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