結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー nobuta05nobuta05
提出日時 2022-04-13 05:29:04
言語 D
(dmd 2.106.1)
結果
TLE  
実行時間 -
コード長 1,575 bytes
コンパイル時間 2,900 ms
コンパイル使用メモリ 155,468 KB
実行使用メモリ 21,876 KB
最終ジャッジ日時 2023-09-04 16:45:49
合計ジャッジ時間 17,298 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.string, std.conv;
import std.algorithm, std.math;
import std.range;
import std.container.rbtree, std.container.dlist;
import std.container.binaryheap, std.container.array;
import std.typecons;
import std.meta;

// import std.meta;

alias mstring = char[];
const long INF = 1L << 60L;
// const long INF = 1L << 30L;
const long mod = 1_000_000_000 + 7;
// const long mod = 998_244_353L;

void chmin (T)(ref T x, T y) {
  x = min(x, y);
}

void chmax (T)(ref T x, T y) {
  x = max(x, y);
}

// 単一の数値を取得
// readln.chomp.to!int;
//  or
// int a;
// readf("%s\n", a);

// 複数の数値を取得(可変数個の場合推奨)
// readln.chomp.split.map!(to!long).array

// 複数の数値を取得(固定数個の場合、推奨)
// int a, b;
// readf("%s %s\n", &a, &b);

// インデントを一個ずらして複数の数値を取得(累積和とかで1-indexedの方が良い時がある)
// long[] vs = readln.chomp.split.map!(to!long).array;
// vs = [0L] ~ vs;

// 小数点は以下で指定
// double ret = 10.0;
// writefln("%.12f", ret);

// 配列の最後の要素は arr[$-1] でアクセスできる

void main () {
  int N = readln.chomp.to!int;
  auto ls = readln.chomp.split.map!(to!double).array;
  long K = readln.chomp.to!long;

  double ac = 0;
  double wa = cast(double) INF;
  while (wa - ac > 0.00000000001) {
    double wj = (ac + wa) / 2.0;

    long cnt = 0;
    foreach (i; 0 .. N)
      cnt += cast(long) floor (ls[i] / wj);

    if (cnt >= K)
      ac = wj;
    else
      wa = wj;
  }

  writefln("%.12f", ac);
}
0