結果

問題 No.1708 Quality of Contest
ユーザー umezoumezo
提出日時 2021-10-15 22:55:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,170 bytes
コンパイル時間 2,379 ms
コンパイル使用メモリ 215,764 KB
実行使用メモリ 20,052 KB
最終ジャッジ日時 2023-10-17 20:47:35
合計ジャッジ時間 6,142 ms
ジャッジサーバーID
(参考情報)
judge13 / 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 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 2 ms
4,348 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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(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<int> 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