結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー nebukuro09nebukuro09
提出日時 2017-06-13 17:22:49
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 826 bytes
コンパイル時間 2,640 ms
コンパイル使用メモリ 182,796 KB
実行使用メモリ 24,612 KB
最終ジャッジ日時 2023-09-03 14:19:18
合計ジャッジ時間 14,349 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

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;

    L.sort();
    auto pq = new BinaryHeap!(Array!(Tuple!(real, int)), "a < b");
    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]);
        pq.insert(tuple(1.0L * L[t[1]] / (i + 1), t[1]));
    }

    
    foreach (i; 0..Q) {
        ans[K[i]].writeln;
    }
}
0