結果

問題 No.1708 Quality of Contest
ユーザー umezoumezo
提出日時 2021-10-15 22:59:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,190 bytes
コンパイル時間 2,814 ms
コンパイル使用メモリ 215,976 KB
実行使用メモリ 22,384 KB
最終ジャッジ日時 2023-10-17 20:50:32
合計ジャッジ時間 6,669 ms
ジャッジサーバーID
(参考情報)
judge11 / 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 RE -
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 96 ms
17,408 KB
testcase_10 AC 112 ms
22,384 KB
testcase_11 AC 105 ms
18,196 KB
testcase_12 AC 104 ms
19,100 KB
testcase_13 AC 109 ms
21,616 KB
testcase_14 AC 104 ms
18,892 KB
testcase_15 AC 94 ms
17,408 KB
testcase_16 AC 102 ms
18,524 KB
testcase_17 AC 106 ms
18,700 KB
testcase_18 AC 106 ms
18,792 KB
testcase_19 AC 104 ms
19,896 KB
testcase_20 AC 105 ms
19,280 KB
testcase_21 AC 99 ms
17,408 KB
testcase_22 AC 97 ms
17,408 KB
testcase_23 AC 99 ms
17,408 KB
testcase_24 AC 109 ms
22,144 KB
testcase_25 AC 109 ms
21,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  ll n,m,x;
  cin>>n>>m>>x;
  vector<ll> A(n),B(n);
  rep(i,n){
    cin>>A[i]>>B[i];
    B[i]--;
  }
  int k;
  cin>>k;
  vector<int> C(k);
  rep(i,k) cin>>C[i];
  
  vector<pair<ll,ll>> D(n);
  rep(i,n) D[i]={A[i],B[i]};
  sort(ALL(D));
  reverse(ALL(D));
  
  priority_queue<pair<ll,ll>> que;
  vector<int> check(n+1);
  
  vector<ll> E,F;
  rep(i,n){
    ll a=D[i].first,b=D[i].second;
    if(check[b]==0){
      while(!que.empty() && que.top().first>a+x){
        auto t=que.top();
        que.pop();
        E.push_back(t.first),F.push_back(t.second);
      }
      check[b]=1;
      E.push_back(a),F.push_back(b);
    }
    else que.push({a,b});
  }
  while(!que.empty()){
    auto t=que.top();
    que.pop();
    E.push_back(t.first),F.push_back(t.second);
  }
  
  vector<ll> G(n+1),S(n+1);
  rep(i,n){
    S[i+1]=S[i]+E[i];
    if(G[F[i]]==0){
      S[i+1]+=x;
      G[F[i]]=1;
    }
  }
  ll ans=0;
  rep(i,k) ans+=S[C[i]];
  cout<<ans<<endl;
    
  return 0;
}
0