結果

問題 No.1708 Quality of Contest
ユーザー ぷらぷら
提出日時 2021-10-15 21:26:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 835 bytes
コンパイル時間 2,188 ms
コンパイル使用メモリ 211,768 KB
実行使用メモリ 16,592 KB
最終ジャッジ日時 2023-10-17 20:01:31
合計ジャッジ時間 7,868 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 5 ms
4,348 KB
testcase_04 AC 5 ms
4,348 KB
testcase_05 AC 6 ms
4,348 KB
testcase_06 AC 5 ms
4,348 KB
testcase_07 AC 5 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 249 ms
16,592 KB
testcase_10 AC 215 ms
11,128 KB
testcase_11 AC 244 ms
9,196 KB
testcase_12 AC 250 ms
10,212 KB
testcase_13 AC 235 ms
8,368 KB
testcase_14 AC 251 ms
10,792 KB
testcase_15 AC 261 ms
14,308 KB
testcase_16 AC 261 ms
13,972 KB
testcase_17 AC 241 ms
11,240 KB
testcase_18 AC 244 ms
11,532 KB
testcase_19 AC 244 ms
12,536 KB
testcase_20 AC 242 ms
11,056 KB
testcase_21 AC 258 ms
11,876 KB
testcase_22 AC 251 ms
10,868 KB
testcase_23 AC 260 ms
14,084 KB
testcase_24 AC 209 ms
6,944 KB
testcase_25 AC 207 ms
6,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N,M,X;
    cin >> N >> M >> X;
    vector<vector<int>>tmp(M);
    for(int i = 0; i < N; i++) {
        int A,B;
        cin >> A >> B;
        B--;
        tmp[B].push_back(A);
    }
    vector<int>res;
    for(int i = 0; i < M; i++) {
        if(tmp[i].empty()) {
            continue;
        }
        sort(tmp[i].rbegin(),tmp[i].rend());
        tmp[i][0] += X;
        for(int j:tmp[i]) {
            res.push_back(j);
        }
    }
    sort(res.rbegin(),res.rend());
    vector<long long>sum(res.size()+1);
    for(int i = 0; i < res.size(); i++) {
        sum[i+1] = sum[i]+res[i];
    }
    long long ans = 0;
    int K;
    cin >> K;
    for(int i = 0; i < K; i++) {
        int C;
        cin >> C;
        ans += sum[C];
    }
    cout << ans << endl;
}
0