結果

問題 No.1708 Quality of Contest
ユーザー planesplanes
提出日時 2021-10-15 22:14:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 937 bytes
コンパイル時間 1,790 ms
コンパイル使用メモリ 177,140 KB
実行使用メモリ 17,324 KB
最終ジャッジ日時 2023-10-17 20:23:32
合計ジャッジ時間 7,462 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 6 ms
4,348 KB
testcase_05 AC 6 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 248 ms
17,324 KB
testcase_10 AC 212 ms
12,656 KB
testcase_11 AC 247 ms
10,960 KB
testcase_12 AC 247 ms
11,832 KB
testcase_13 AC 241 ms
10,168 KB
testcase_14 AC 249 ms
12,232 KB
testcase_15 AC 260 ms
15,300 KB
testcase_16 AC 260 ms
14,988 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 256 ms
13,080 KB
testcase_22 AC 251 ms
12,304 KB
testcase_23 AC 260 ms
15,092 KB
testcase_24 AC 206 ms
8,788 KB
testcase_25 AC 204 ms
8,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

int main() {
    ll N,M,X;cin>>N>>M>>X;
    vector<vector<ll>> vec(M,vector<ll> (0));
    for(ll i=0;i<N;i++) {
        ll A,B;cin>>A>>B;
        B--;
        vec[B].push_back(A);
    }

    for(ll i=0;i<M;i++) {
    pair<ll,ll> a={0,-1};
        for(ll j=0;j<vec[i].size();j++) {
            if(a.first<vec[i][j]) {
                a.first=vec[i][j];
                a.second=j;
            }
        }

    if(a.second>=0) vec[i][a.second]+=X;
    }

vector<ll> note(0);
for(ll i=0;i<M;i++) {
    for(auto x:vec[i]) note.push_back(x);
}
sort(all(note));
reverse(all(note));

vector<ll> r(N+1);
r[0]=0;
for(ll i=0;i<N;i++) {
    r[i+1]=r[i]+note[i];
}

ll K;cin>>K;
ll ans=0;
for(ll i=0;i<K;i++) {
    ll C;cin>>C;
    ans+=r[C];
}
cout<<ans<<endl;
}
0