結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー youthfuldays072youthfuldays072
提出日時 2018-06-16 18:16:36
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,031 bytes
コンパイル時間 1,933 ms
コンパイル使用メモリ 74,108 KB
実行使用メモリ 67,124 KB
最終ジャッジ日時 2023-09-13 06:10:58
合計ジャッジ時間 26,050 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 909 ms
67,080 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 895 ms
67,108 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 892 ms
67,076 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 813 ms
64,632 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 841 ms
64,548 KB
testcase_16 AC 852 ms
67,048 KB
testcase_17 AC 819 ms
66,884 KB
testcase_18 AC 815 ms
67,036 KB
testcase_19 AC 904 ms
66,760 KB
testcase_20 AC 893 ms
66,676 KB
testcase_21 AC 946 ms
66,584 KB
testcase_22 AC 809 ms
66,880 KB
testcase_23 AC 799 ms
66,936 KB
testcase_24 AC 117 ms
56,368 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 189 ms
55,992 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Main main=new Main();
		main.run();
	}

	void run() {


		Scanner sc=new Scanner(System.in);

		int N=sc.nextInt();

		long[] L=new long[N];

		long maxlength=-1;
		for(int i=0;i<N;i++) {

			long buf=sc.nextLong();
			L[i]=buf;

			if(maxlength<buf) {
				maxlength=buf;
			}
		}

		Long K=sc.nextLong();

		double l=0.0;
		double u=maxlength+1;
		double mid=0.0;

		for(int i=0;i<100;i++) {
			mid=(l+u)/2.0;

			if(judge(mid,L,K)) {
				l=mid;
			}else {
				u=mid;
			}
		}



		System.out.println(mid);




	}



	//ある幅で何本とれるか返す関数
	public static int calc(double cutwidth,long[] L) {

		int count=0;

		for(int i=0;i<L.length;i++) {
			count+=(int)L[i]/cutwidth;
		}


		return count;
	}

	//ある幅でK本以上とれるかどうか判定する関数。
	public static boolean judge(double cutwidth,long[] L,long K) {

		if(calc(cutwidth,L)>=K) {
			return true;
		}else {
			return false;
		}

	}




}

0