結果
| 問題 |
No.1708 Quality of Contest
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2021-11-01 13:50:26 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 253 ms / 2,000 ms |
| コード長 | 1,470 bytes |
| コンパイル時間 | 3,449 ms |
| コンパイル使用メモリ | 143,600 KB |
| 実行使用メモリ | 8,912 KB |
| 最終ジャッジ日時 | 2024-10-10 02:21:56 |
| 合計ジャッジ時間 | 9,611 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
struct Node {
ll value;
int type;
bool has_bonus;
Node(ll value = -1, int type = -1, bool has_bonus = true) {
this->value = value;
this->type = type;
this->has_bonus = has_bonus;
}
bool operator>(const Node &n) const {
return value < n.value;
}
};
int main() {
int N, M;
ll X;
cin >> N >> M >> X;
priority_queue <Node, vector<Node>, greater<Node>> pque;
for (int i = 0; i < N; ++i) {
int a, b;
cin >> a >> b;
pque.push(Node(a + X, b, true));
}
int K;
cin >> K;
vector<int> C(K);
for (int i = 0; i < K; ++i) {
cin >> C[i];
}
int cnt = 0;
ll values[N + 1];
memset(values, 0, sizeof(values));
ll sum = 0;
priority_queue <Node, vector<Node>, greater<Node>> pque_2;
bool checked[M + 1];
memset(checked, false, sizeof(checked));
while (not pque.empty()) {
Node node = pque.top();
pque.pop();
if (checked[node.type] && node.has_bonus) {
node.value -= X;
node.has_bonus = false;
pque.push(node);
continue;
}
checked[node.type] = true;
sum += node.value;
cnt++;
values[cnt] = sum;
}
ll ans = 0;
for (int c : C) {
ans += values[c];
}
cout << ans << endl;
return 0;
}
siman