結果

問題 No.1708 Quality of Contest
コンテスト
ユーザー kokatsu
提出日時 2021-10-15 21:42:23
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 240 ms / 2,000 ms
コード長 800 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,917 ms
コンパイル使用メモリ 218,360 KB
実行使用メモリ 21,896 KB
最終ジャッジ日時 2026-03-06 18:26:02
合計ジャッジ時間 5,203 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/core/checkedint.d(814): Warning: cannot inline function `core.checkedint.mulu!().mulu`
ulong mulu()(ulong x, uint y, ref bool overflow)
      ^

ソースコード

diff #
raw source code

import std;

void main() {
    int N, M ,X;
    readf("%d %d %d\n", N, M, X);

    auto A = new long[](N), B = new long[](N);
    foreach (i; 0 .. N) {
        readf("%d %d\n", A[i], B[i]);
    }

    int K;
    readf("%d\n", K);

    auto C = readln.chomp.split.to!(long[]);

    zip(A, B).sort!((a, b) => a[0] > b[0]);
    auto used = new bool[](M+1);
    auto heap = new BinaryHeap!(Array!long, "a < b")();
    foreach (i; 0 .. N) {
        if (used[B[i]]) {
            heap.insert(A[i]);
        }
        else {
            heap.insert(A[i]+X);
            used[B[i]] = true;
        }
    }

    auto cumsum = heap.array.cumulativeFold!"a + b".array;
    long res;
    foreach (c; C) {
        if (c == 0) {
            continue;
        }
        res += cumsum[c-1];
    }

    res.writeln;
}
0