結果

問題 No.1708 Quality of Contest
ユーザー umezoumezo
提出日時 2021-10-15 23:00:38
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 1,169 bytes
コンパイル時間 2,369 ms
コンパイル使用メモリ 215,804 KB
実行使用メモリ 22,392 KB
最終ジャッジ日時 2023-10-17 20:51:41
合計ジャッジ時間 6,207 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 3 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 4 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 94 ms
17,416 KB
testcase_10 AC 115 ms
22,392 KB
testcase_11 AC 108 ms
16,592 KB
testcase_12 AC 107 ms
17,868 KB
testcase_13 AC 110 ms
19,280 KB
testcase_14 AC 106 ms
17,716 KB
testcase_15 AC 98 ms
17,416 KB
testcase_16 AC 105 ms
18,492 KB
testcase_17 AC 107 ms
17,580 KB
testcase_18 AC 106 ms
17,964 KB
testcase_19 AC 106 ms
18,376 KB
testcase_20 AC 107 ms
18,144 KB
testcase_21 AC 100 ms
16,608 KB
testcase_22 AC 98 ms
16,240 KB
testcase_23 AC 101 ms
17,388 KB
testcase_24 AC 111 ms
20,272 KB
testcase_25 AC 111 ms
19,480 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];
  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(m+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(m+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