結果
問題 | No.1708 Quality of Contest |
ユーザー |
![]() |
提出日時 | 2021-10-15 22:59:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,190 bytes |
コンパイル時間 | 2,656 ms |
コンパイル使用メモリ | 206,848 KB |
最終ジャッジ日時 | 2025-01-25 01:05:47 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 RE * 3 |
ソースコード
#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;}