結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー nebukuro09nebukuro09
提出日時 2017-06-13 17:26:03
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 666 ms / 5,000 ms
コード長 884 bytes
コンパイル時間 3,598 ms
コンパイル使用メモリ 178,268 KB
実行使用メモリ 24,552 KB
最終ジャッジ日時 2023-09-03 14:19:56
合計ジャッジ時間 16,873 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 664 ms
23,644 KB
testcase_01 AC 665 ms
24,492 KB
testcase_02 AC 666 ms
24,552 KB
testcase_03 AC 602 ms
23,592 KB
testcase_04 AC 612 ms
23,684 KB
testcase_05 AC 607 ms
23,024 KB
testcase_06 AC 620 ms
22,564 KB
testcase_07 AC 634 ms
23,868 KB
testcase_08 AC 595 ms
22,316 KB
testcase_09 AC 592 ms
23,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;


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

    auto M = new int[](N);
    
    auto pq = new BinaryHeap!(Array!(Tuple!(real, int)), "a[0] < b[0]");
    foreach (i; 0..N) pq.insert(tuple(L[i].to!real, i));

    auto ans = new real[](5*10^^5+1);
    ans[0] = 1L << 60;
    
    foreach (i; 1..5*10^^5+1) {
        auto t = pq.front;
        pq.popFront;
        ans[i] = min(ans[i-1], t[0]);
        M[t[1]] += 1;
        pq.insert(tuple(1.0L * L[t[1]] / (M[t[1]] + 1), t[1]));
    }

    foreach (i; 0..Q) {
        writefln("%.10f", ans[K[i]]);
    }
}
0