結果

問題 No.1708 Quality of Contest
ユーザー hourenhouren
提出日時 2021-10-15 22:13:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 329 ms / 2,000 ms
コード長 850 bytes
コンパイル時間 1,851 ms
コンパイル使用メモリ 183,612 KB
実行使用メモリ 18,968 KB
最終ジャッジ日時 2023-10-17 20:22:50
合計ジャッジ時間 8,292 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 6 ms
4,348 KB
testcase_04 AC 7 ms
4,348 KB
testcase_05 AC 7 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 313 ms
18,968 KB
testcase_10 AC 230 ms
9,516 KB
testcase_11 AC 297 ms
12,084 KB
testcase_12 AC 306 ms
13,072 KB
testcase_13 AC 292 ms
11,260 KB
testcase_14 AC 312 ms
13,616 KB
testcase_15 AC 326 ms
15,484 KB
testcase_16 AC 329 ms
15,408 KB
testcase_17 AC 292 ms
13,276 KB
testcase_18 AC 295 ms
13,340 KB
testcase_19 AC 300 ms
14,288 KB
testcase_20 AC 288 ms
12,968 KB
testcase_21 AC 314 ms
14,304 KB
testcase_22 AC 308 ms
13,644 KB
testcase_23 AC 328 ms
15,432 KB
testcase_24 AC 246 ms
9,532 KB
testcase_25 AC 243 ms
9,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
using P = pair<ll,int>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,m,x,k;
    cin >> n >> m >> x;
    vector<P> ab(n);
    rep(i,n) cin >> ab[i].first >> ab[i].second;
    sort(all(ab)); reverse(all(ab));
    priority_queue<ll> pq;
    set<int> se;
    rep(i,n){
        ll p = 0;
        if(!se.count(ab[i].second)) p += x;
        p += ab[i].first;
        pq.push(p);
        se.insert(ab[i].second);
    }
    vector<ll> pls(n+1);
    pls[0] = 0;
    ll tot = 0, ans = 0;
    rep(i,n){
        tot += pq.top();
        pq.pop();
        pls[i+1] = tot;
    }
    cin >> k;
    rep(i,k){
        int c;
        cin >> c;
        ans += pls[c];
    }
    cout << ans << endl;
    return 0;
}
0