結果

問題 No.1708 Quality of Contest
ユーザー erbowlerbowl
提出日時 2022-08-20 14:38:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 344 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 2,434 ms
コンパイル使用メモリ 209,768 KB
実行使用メモリ 22,000 KB
最終ジャッジ日時 2024-04-17 13:25:02
合計ジャッジ時間 9,790 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 6 ms
5,376 KB
testcase_04 AC 7 ms
5,376 KB
testcase_05 AC 6 ms
5,376 KB
testcase_06 AC 5 ms
5,376 KB
testcase_07 AC 5 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 323 ms
22,000 KB
testcase_10 AC 217 ms
9,444 KB
testcase_11 AC 278 ms
13,056 KB
testcase_12 AC 292 ms
14,336 KB
testcase_13 AC 270 ms
11,776 KB
testcase_14 AC 298 ms
14,848 KB
testcase_15 AC 314 ms
17,408 KB
testcase_16 AC 344 ms
17,152 KB
testcase_17 AC 284 ms
14,336 KB
testcase_18 AC 283 ms
14,720 KB
testcase_19 AC 292 ms
15,872 KB
testcase_20 AC 277 ms
14,464 KB
testcase_21 AC 309 ms
15,872 KB
testcase_22 AC 300 ms
14,976 KB
testcase_23 AC 329 ms
17,408 KB
testcase_24 AC 239 ms
9,600 KB
testcase_25 AC 234 ms
9,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ll n,m,x;
    std::cin >> n>>m>>x;
    vector<pair<ll,ll>> ab(n);
    for (int i = 0; i < n; i++) {
        std::cin >> ab[i].first >> ab[i].second;
    }
    ll k;
    std::cin >> k;
    vector<ll> c(k);
    for (int i = 0; i < k; i++) {
        std::cin >> c[i];
    }
    
    sort(ab.rbegin(),ab.rend());
    map<ll,bool> used;
    for (int i = 0; i < n; i++) {
        if(used[ab[i].second]){
            
        }else{
            used[ab[i].second]=true;
            ab[i].first+=x;
        }
    }
    sort(ab.rbegin(),ab.rend());
    vector<ll> sum(n+1);
    for (int i = 0; i < n; i++) {
        sum[i+1] = sum[i]+ab[i].first;
    }
    ll ans = 0;
    for (int i = 0; i < k; i++) {
        ans += sum[c[i]];
    }
    std::cout << ans << std::endl;
}
0