結果

問題 No.1708 Quality of Contest
ユーザー karinohitokarinohito
提出日時 2023-09-25 02:59:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 765 bytes
コンパイル時間 2,696 ms
コンパイル使用メモリ 206,428 KB
実行使用メモリ 17,024 KB
最終ジャッジ日時 2023-09-25 02:59:59
合計ジャッジ時間 10,278 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 5 ms
4,376 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 242 ms
17,024 KB
testcase_10 AC 200 ms
12,524 KB
testcase_11 AC 232 ms
10,732 KB
testcase_12 AC 263 ms
11,540 KB
testcase_13 AC 226 ms
10,220 KB
testcase_14 AC 240 ms
12,036 KB
testcase_15 AC 250 ms
15,208 KB
testcase_16 AC 249 ms
14,696 KB
testcase_17 AC 227 ms
12,456 KB
testcase_18 AC 233 ms
12,668 KB
testcase_19 AC 264 ms
13,616 KB
testcase_20 AC 231 ms
12,580 KB
testcase_21 AC 242 ms
12,852 KB
testcase_22 AC 242 ms
12,140 KB
testcase_23 AC 251 ms
14,852 KB
testcase_24 AC 196 ms
8,540 KB
testcase_25 AC 202 ms
8,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ll N,M,X;
    cin>>N>>M>>X;
    vector<vector<ll>> A(M);
    rep(i,N){
        ll a,b;
        cin>>a>>b;
        A[b-1].push_back(a);
    }
    vector<ll> P;
    rep(i,M){
        if(ll(A[i].size())==0)continue;
        sort(all(A[i]));
        reverse(all(A[i]));
        ll cnt=1;
        for(auto a:A[i]){
            P.push_back(a+X*cnt);
            cnt=0;
        }
    }
    
    sort(all(P));
    reverse(all(P));
    vector<ll> PS(N+1,0);
    rep(i,N)PS[i+1]+=PS[i]+P[i];
    
    ll an=0;
    ll K;
    cin>>K;
    rep(i,K){
        ll c;
        cin>>c;
        an+=PS[c];
    }
    cout<<an<<endl;

}
0