結果

問題 No.1708 Quality of Contest
ユーザー rogi52rogi52
提出日時 2022-10-06 18:58:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 744 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 210,120 KB
実行使用メモリ 17,204 KB
最終ジャッジ日時 2023-09-01 23:50:38
合計ジャッジ時間 5,980 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 112 ms
17,204 KB
testcase_10 AC 84 ms
12,420 KB
testcase_11 AC 111 ms
10,652 KB
testcase_12 AC 113 ms
11,712 KB
testcase_13 AC 102 ms
10,036 KB
testcase_14 AC 114 ms
12,112 KB
testcase_15 AC 128 ms
15,004 KB
testcase_16 AC 128 ms
14,796 KB
testcase_17 AC 113 ms
12,452 KB
testcase_18 AC 112 ms
12,836 KB
testcase_19 AC 116 ms
13,540 KB
testcase_20 AC 109 ms
12,584 KB
testcase_21 AC 123 ms
12,964 KB
testcase_22 AC 118 ms
12,124 KB
testcase_23 AC 124 ms
14,968 KB
testcase_24 AC 85 ms
8,672 KB
testcase_25 AC 84 ms
8,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll N,M,X; cin >> N >> M >> X;
    vector<vector<ll>> col(M);
    rep(i,N) {
        ll A,B; cin >> A >> B; B--;
        col[B].push_back(A);
    }

    vector<ll> D;
    rep(i,M) if(!col[i].empty()) {
        sort(col[i].begin(), col[i].end());
        col[i].back() += X;
        for(ll x : col[i]) D.push_back(x);
    }
    sort(D.rbegin(), D.rend());

    vector<ll> sumD(N + 1, 0);
    rep(i,N) sumD[i + 1] += sumD[i] + D[i];
    ll ans = 0;
    int K; cin >> K;
    rep(i,K) {
        int c; cin >> c;
        ans += sumD[c];
    }
    cout << ans << endl;
}
0