結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー youthfuldays072youthfuldays072
提出日時 2018-06-16 18:44:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,152 ms / 5,000 ms
コード長 1,127 bytes
コンパイル時間 2,614 ms
コンパイル使用メモリ 74,604 KB
実行使用メモリ 69,476 KB
最終ジャッジ日時 2024-04-26 00:34:51
合計ジャッジ時間 31,448 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,091 ms
68,864 KB
testcase_01 AC 140 ms
54,440 KB
testcase_02 AC 689 ms
60,604 KB
testcase_03 AC 954 ms
69,188 KB
testcase_04 AC 1,063 ms
69,400 KB
testcase_05 AC 1,076 ms
68,976 KB
testcase_06 AC 1,134 ms
69,084 KB
testcase_07 AC 1,152 ms
68,728 KB
testcase_08 AC 1,115 ms
69,068 KB
testcase_09 AC 1,095 ms
69,476 KB
testcase_10 AC 1,062 ms
69,292 KB
testcase_11 AC 1,054 ms
69,152 KB
testcase_12 AC 1,061 ms
69,388 KB
testcase_13 AC 1,096 ms
69,228 KB
testcase_14 AC 1,077 ms
68,568 KB
testcase_15 AC 1,050 ms
69,124 KB
testcase_16 AC 1,102 ms
69,128 KB
testcase_17 AC 1,109 ms
69,352 KB
testcase_18 AC 1,078 ms
69,124 KB
testcase_19 AC 1,113 ms
68,592 KB
testcase_20 AC 1,103 ms
68,836 KB
testcase_21 AC 1,148 ms
68,772 KB
testcase_22 AC 1,050 ms
69,312 KB
testcase_23 AC 1,090 ms
69,244 KB
testcase_24 AC 134 ms
54,360 KB
testcase_25 AC 235 ms
57,576 KB
testcase_26 AC 206 ms
56,912 KB
testcase_27 AC 203 ms
54,112 KB
testcase_28 AC 522 ms
59,120 KB
testcase_29 AC 369 ms
58,800 KB
testcase_30 AC 247 ms
57,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{
	int[] L;
	int N;
	long K;

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

	void run() {

		Scanner sc=new Scanner(System.in);

		 N=sc.nextInt();
		 L=new int[N];

		for(int i=0;i<N;i++) {
			int buf=sc.nextInt();
			L[i]=buf;
		}

		K=sc.nextLong();

		double ub=Integer.MAX_VALUE;
		double lb=0;
		double mid=0;

		for(int i=0;i<100;i++) {

			mid=(lb+ub)/2;
			long temp=0;

			for(int l=0;l<N;l++) {
				temp+=(long)L[l]/mid;
			}

			if(temp>=K) {
				lb=mid;
			}else {
				ub=mid;
			}

		}

		System.out.println(lb);


	}

}


//#include "bits/stdc++.h"
//using namespace std;
//
//
//int main(){
//	int N;
//	cin >> N;
//	vector<int> L(N);
//	for (int i = 0; i < N; i++)
//	{
//		cin >> L[i];
//	}
//
//	long long K;
//	cin >> K;
//
//	double low = 0;
//	double high = 1e9;
//	for (int t = 0; t < 100; t++)
//	{
//		double mid = (low + high) / 2;
//		long temp = 0;
//		for (int i = 0; i < N; i++)
//		{
//			temp += (long long)(L[i] / mid);
//		}
//		if (temp >= K) low = mid;
//		else high = mid;
//	}
//	printf("%.14f\n", low);
//}
0