結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー nobuta05nobuta05
提出日時 2022-04-13 05:47:53
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 597 ms / 5,000 ms
コード長 1,552 bytes
コンパイル時間 2,103 ms
コンパイル使用メモリ 155,456 KB
実行使用メモリ 17,096 KB
最終ジャッジ日時 2023-09-04 16:46:49
合計ジャッジ時間 15,026 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 446 ms
14,548 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 213 ms
6,176 KB
testcase_03 AC 415 ms
9,564 KB
testcase_04 AC 559 ms
15,144 KB
testcase_05 AC 558 ms
17,096 KB
testcase_06 AC 539 ms
15,692 KB
testcase_07 AC 597 ms
13,248 KB
testcase_08 AC 595 ms
13,400 KB
testcase_09 AC 500 ms
13,240 KB
testcase_10 AC 500 ms
9,868 KB
testcase_11 AC 530 ms
15,144 KB
testcase_12 AC 464 ms
9,928 KB
testcase_13 AC 546 ms
13,260 KB
testcase_14 AC 566 ms
13,388 KB
testcase_15 AC 427 ms
13,440 KB
testcase_16 AC 449 ms
15,488 KB
testcase_17 AC 426 ms
15,620 KB
testcase_18 AC 417 ms
16,316 KB
testcase_19 AC 433 ms
13,204 KB
testcase_20 AC 423 ms
13,252 KB
testcase_21 AC 422 ms
13,152 KB
testcase_22 AC 372 ms
11,580 KB
testcase_23 AC 395 ms
16,092 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 11 ms
4,380 KB
testcase_26 AC 5 ms
4,380 KB
testcase_27 AC 4 ms
4,376 KB
testcase_28 AC 86 ms
5,328 KB
testcase_29 AC 41 ms
4,376 KB
testcase_30 AC 12 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.d(60): Warning: `long += real` is performing truncating conversion

ソースコード

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!real).array;
  long K = readln.chomp.to!long;

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

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

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

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