結果

問題 No.1708 Quality of Contest
ユーザー abc3abc3
提出日時 2021-10-16 05:37:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 1,441 bytes
コンパイル時間 2,436 ms
コンパイル使用メモリ 217,056 KB
実行使用メモリ 18,100 KB
最終ジャッジ日時 2023-10-17 22:03:34
合計ジャッジ時間 5,910 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 3 ms
4,348 KB
testcase_04 AC 4 ms
4,348 KB
testcase_05 AC 4 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 4 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 117 ms
18,100 KB
testcase_10 AC 88 ms
12,636 KB
testcase_11 AC 114 ms
10,716 KB
testcase_12 AC 119 ms
11,720 KB
testcase_13 AC 108 ms
9,856 KB
testcase_14 AC 122 ms
12,300 KB
testcase_15 AC 133 ms
15,816 KB
testcase_16 AC 131 ms
15,480 KB
testcase_17 AC 117 ms
12,748 KB
testcase_18 AC 119 ms
13,040 KB
testcase_19 AC 122 ms
14,048 KB
testcase_20 AC 115 ms
12,564 KB
testcase_21 AC 125 ms
13,384 KB
testcase_22 AC 119 ms
12,376 KB
testcase_23 AC 133 ms
15,592 KB
testcase_24 AC 86 ms
8,448 KB
testcase_25 AC 87 ms
8,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    using P=pair<ll,ll>;
    const ll INF=1e18;
    const int mod=1e9+7;

    void solve(){
        ll n,m,x;
        cin>>n>>m>>x;
        vector<vector<int>>t(m);
        rep(i,n){
            int a,b;
            cin>>a>>b;b--;
            t[b].push_back(a);
        }
        int k;
        cin>>k;
        vector<int>c(k);
        rep(i,k)cin>>c[i];
        
        vector<ll>a;
        rep(i,m){sort(t[i].rbegin(),t[i].rend());}
        rep(i,m){
            if(t[i].empty()){continue;}
            a.push_back(t[i][0]+x);
            for(int j=1;j<t[i].size();j++){a.push_back(t[i][j]);}
        }
        sort(a.rbegin(),a.rend());
        vector<ll>sum(a.size()+1);
        rep(i,a.size()){sum[i+1]=sum[i]+a[i];}
        ll ans=0;
        rep(i,k){ans+=sum[c[i]];}
        cout<<ans<<endl;
    } 

    int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        
        solve();

        return 0;
    }
0