結果

問題 No.1708 Quality of Contest
ユーザー monnumonnu
提出日時 2021-10-15 21:53:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 859 bytes
コンパイル時間 4,013 ms
コンパイル使用メモリ 234,476 KB
実行使用メモリ 17,428 KB
最終ジャッジ日時 2023-10-17 20:15:25
合計ジャッジ時間 9,626 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 5 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 251 ms
17,428 KB
testcase_10 AC 217 ms
12,760 KB
testcase_11 AC 247 ms
11,064 KB
testcase_12 AC 253 ms
11,936 KB
testcase_13 AC 239 ms
10,272 KB
testcase_14 AC 250 ms
12,336 KB
testcase_15 AC 263 ms
15,404 KB
testcase_16 AC 263 ms
15,092 KB
testcase_17 AC 241 ms
12,800 KB
testcase_18 AC 244 ms
13,060 KB
testcase_19 AC 246 ms
13,960 KB
testcase_20 AC 246 ms
12,632 KB
testcase_21 AC 259 ms
13,184 KB
testcase_22 AC 253 ms
12,408 KB
testcase_23 AC 264 ms
15,196 KB
testcase_24 AC 208 ms
8,892 KB
testcase_25 AC 207 ms
8,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define INF 1000000000
#define MOD 998244353
#define MAX 200000

int main(){
  int N,M;
  ll X;
  cin>>N>>M>>X;
  vector<vector<ll>> A(M);
  for(int i=0;i<N;i++){
    ll a;
    int b;
    cin>>a>>b;
    b--;
    A[b].push_back(a);
  }
  vector<ll> B;
  for(int i=0;i<M;i++){
    if(A[i].size()==0){
      continue;
    }
    sort(A[i].begin(),A[i].end(),greater<ll>());
    B.push_back(A[i][0]+X);
    for(int j=1;j<A[i].size();j++){
      B.push_back(A[i][j]);
    }
  }
  sort(B.begin(),B.end(),greater<ll>());
  vector<ll> sum(N+1,0);
  for(int i=0;i<N;i++){
    sum[i+1]=sum[i]+B[i];
  }
  ll ans=0;
  int K;
  cin>>K;
  for(int i=0;i<K;i++){
    int C;
    cin>>C;
    ans+=sum[C];
  }
  cout<<ans<<'\n';
}
0