結果
| 問題 |
No.1708 Quality of Contest
|
| コンテスト | |
| ユーザー |
se1ka2
|
| 提出日時 | 2021-10-15 21:51:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 197 ms / 2,000 ms |
| コード長 | 1,083 bytes |
| コンパイル時間 | 807 ms |
| コンパイル使用メモリ | 81,332 KB |
| 実行使用メモリ | 9,068 KB |
| 最終ジャッジ日時 | 2024-09-17 17:26:09 |
| 合計ジャッジ時間 | 5,209 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
int main()
{
int n, m;
ll x;
cin >> n >> m >> x;
P p[200005];
for(int i = 0; i < n; i++){
int a, b;
cin >> a >> b;
p[i] = P(a, b);
}
sort(p, p + n, greater<P>());
int k;
cin >> k;
int d[200005]{0};
for(int i = 0; i < k; i++){
int c;
cin >> c;
d[c]++;
}
int j = 0;
int c = k;
ll ans = 0;
queue<ll> que;
bool b[200005]{0};
for(int i = 0; i < n; i++){
if(!b[p[i].second]){
b[p[i].second] = true;
while(!que.empty() && que.front() >= p[i].first + x){
c -= d[j++];
ans += que.front() * c;
que.pop();
}
c -= d[j++];
ans += (p[i].first + x) * c;
}
else que.push(p[i].first);
}
while(!que.empty()){
c -= d[j++];
ans += que.front() * c;
que.pop();
}
cout << ans << endl;
}
se1ka2