結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー 👑 hos.lyrichos.lyric
提出日時 2014-11-25 04:59:32
言語 D
(dmd 2.106.1)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,115 bytes
コンパイル時間 2,305 ms
コンパイル使用メモリ 164,084 KB
実行使用メモリ 13,424 KB
最終ジャッジ日時 2023-09-02 19:14:26
合計ジャッジ時間 11,739 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 351 ms
11,404 KB
testcase_01 WA -
testcase_02 AC 150 ms
6,692 KB
testcase_03 AC 289 ms
10,624 KB
testcase_04 AC 372 ms
11,532 KB
testcase_05 AC 371 ms
11,068 KB
testcase_06 AC 345 ms
11,520 KB
testcase_07 AC 417 ms
12,016 KB
testcase_08 AC 415 ms
11,920 KB
testcase_09 AC 345 ms
12,980 KB
testcase_10 AC 334 ms
10,104 KB
testcase_11 AC 354 ms
11,360 KB
testcase_12 AC 299 ms
10,460 KB
testcase_13 AC 381 ms
12,204 KB
testcase_14 AC 394 ms
11,212 KB
testcase_15 AC 295 ms
12,580 KB
testcase_16 AC 269 ms
11,132 KB
testcase_17 AC 248 ms
11,024 KB
testcase_18 AC 238 ms
11,256 KB
testcase_19 AC 259 ms
11,784 KB
testcase_20 AC 247 ms
13,424 KB
testcase_21 AC 249 ms
13,016 KB
testcase_22 AC 214 ms
10,564 KB
testcase_23 AC 229 ms
11,464 KB
testcase_24 AC 1 ms
4,368 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 3 ms
4,368 KB
testcase_28 AC 62 ms
4,408 KB
testcase_29 AC 30 ms
4,368 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import core.thread;
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex;

//	Input
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { tokens = readln.split; if (stdin.eof) throw new EOFException; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return to!int(readToken); }
long readLong() { return to!long(readToken); }
real readReal() { return to!real(readToken); }

//	chmin/chmax
void chmin(T)(ref T t, in T f) { if (t > f) t = f; }
void chmax(T)(ref T t, in T f) { if (t < f) t = f; }

//	Pair
struct Pair(S, T) {
	S x; T y;
	int opCmp(    const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }
	int opCmp(ref const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }
	string toString() const { return "(" ~ to!string(x) ~ ", " ~ to!string(y) ~ ")"; }
}
auto pair(S, T)(inout(S) x, inout(T) y) { return Pair!(S, T)(x, y); }

//	Array
int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = as.length; for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) { return (a <  val); }); }
int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) { return (a <= val); }); }
T[] unique(T)(in T[] as) { T[] bs; foreach (a; as) if (bs.empty || bs[$ - 1] != a) bs ~= a; return bs; }


int N;
real[] L;
long K;

void main(string[] args) {
	try {
	for (; ; ) {
		N = readInt;
		L = new real[N];
		foreach (i; 0 .. N) {
			L[i] = readReal;
		}
		K = readLong;
		
		real lo = 0.0, ho = L.reduce!max;
		foreach (_; 0 .. 50) {
			real mo = (lo + ho) / 2.0;
			long sum;
			foreach (i; 0 .. N) {
				sum += cast(long)(floor(L[i] / mo));
			}
			(sum >= K) ? (lo = mo) : (ho = mo);
		}
		writefln("%.10f", lo);
		
	}
	} catch (EOFException) {}
}
0