結果

問題 No.1708 Quality of Contest
ユーザー kokatsukokatsu
提出日時 2021-10-15 21:42:23
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 234 ms / 2,000 ms
コード長 800 bytes
コンパイル時間 3,479 ms
コンパイル使用メモリ 232,396 KB
実行使用メモリ 22,140 KB
最終ジャッジ日時 2023-09-04 14:29:10
合計ジャッジ時間 11,324 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 6 ms
4,376 KB
testcase_04 AC 6 ms
4,380 KB
testcase_05 AC 6 ms
4,380 KB
testcase_06 AC 5 ms
4,376 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 204 ms
20,920 KB
testcase_10 AC 227 ms
20,016 KB
testcase_11 AC 232 ms
20,332 KB
testcase_12 AC 232 ms
19,816 KB
testcase_13 AC 229 ms
20,784 KB
testcase_14 AC 232 ms
19,912 KB
testcase_15 AC 231 ms
19,940 KB
testcase_16 AC 234 ms
21,088 KB
testcase_17 AC 229 ms
22,140 KB
testcase_18 AC 229 ms
20,684 KB
testcase_19 AC 227 ms
21,248 KB
testcase_20 AC 229 ms
20,952 KB
testcase_21 AC 234 ms
20,032 KB
testcase_22 AC 231 ms
19,896 KB
testcase_23 AC 231 ms
21,060 KB
testcase_24 AC 224 ms
21,748 KB
testcase_25 AC 226 ms
20,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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