結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー noriocnorioc
提出日時 2017-08-19 01:01:48
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 219 ms / 5,000 ms
コード長 882 bytes
コンパイル時間 2,418 ms
コンパイル使用メモリ 152,716 KB
実行使用メモリ 13,904 KB
最終ジャッジ日時 2023-09-03 16:00:14
合計ジャッジ時間 11,149 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 219 ms
13,340 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 81 ms
5,748 KB
testcase_03 AC 155 ms
9,128 KB
testcase_04 AC 210 ms
13,724 KB
testcase_05 AC 209 ms
12,560 KB
testcase_06 AC 208 ms
13,280 KB
testcase_07 AC 214 ms
12,264 KB
testcase_08 AC 213 ms
12,260 KB
testcase_09 AC 212 ms
12,968 KB
testcase_10 AC 188 ms
9,896 KB
testcase_11 AC 200 ms
13,904 KB
testcase_12 AC 181 ms
9,404 KB
testcase_13 AC 197 ms
12,140 KB
testcase_14 AC 204 ms
11,972 KB
testcase_15 AC 183 ms
12,100 KB
testcase_16 AC 209 ms
12,864 KB
testcase_17 AC 210 ms
12,712 KB
testcase_18 AC 210 ms
12,660 KB
testcase_19 AC 213 ms
12,036 KB
testcase_20 AC 215 ms
12,936 KB
testcase_21 AC 214 ms
12,852 KB
testcase_22 AC 188 ms
9,948 KB
testcase_23 AC 199 ms
13,728 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 5 ms
4,380 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 35 ms
5,312 KB
testcase_29 AC 19 ms
4,376 KB
testcase_30 AC 6 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.d(21): Warning: `long += double` is performing truncating conversion

ソースコード

diff #

import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

bool can(double len, long k, long[] ls) {
    long n = 0;
    foreach (x; ls) {
        n += x / len;
    }
    return n >= k;
}

double calc(long k, long[] ls) {
    double ans = 0;
    double lo = 0;
    double hi = 10 ^^ 9;
    foreach (_; 0 .. 100) {
        auto m = (lo + hi) / 2;
        if (can(m, k, ls)) {
            ans = max(ans, m);
            lo = m;
        }
        else {
            hi = m;
        }
    }
    return ans;
}

void main() {
    readln;
    auto ls = readln.split.map!(to!long).array;
    long k = readln.chomp.to!long;

    auto ans = calc(k, ls);
    writefln("%.9f", ans);
}
0