結果

問題 No.1708 Quality of Contest
ユーザー simansiman
提出日時 2021-11-01 13:50:26
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 241 ms / 2,000 ms
コード長 1,470 bytes
コンパイル時間 1,684 ms
コンパイル使用メモリ 144,616 KB
実行使用メモリ 9,484 KB
最終ジャッジ日時 2024-04-18 09:04:13
合計ジャッジ時間 7,668 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 5 ms
6,944 KB
testcase_04 AC 4 ms
6,944 KB
testcase_05 AC 5 ms
6,944 KB
testcase_06 AC 4 ms
6,944 KB
testcase_07 AC 4 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 190 ms
8,872 KB
testcase_10 AC 237 ms
9,160 KB
testcase_11 AC 226 ms
8,768 KB
testcase_12 AC 218 ms
8,904 KB
testcase_13 AC 238 ms
8,576 KB
testcase_14 AC 224 ms
8,600 KB
testcase_15 AC 226 ms
8,936 KB
testcase_16 AC 224 ms
8,820 KB
testcase_17 AC 224 ms
9,484 KB
testcase_18 AC 231 ms
8,728 KB
testcase_19 AC 218 ms
8,928 KB
testcase_20 AC 227 ms
8,732 KB
testcase_21 AC 225 ms
8,776 KB
testcase_22 AC 221 ms
8,800 KB
testcase_23 AC 223 ms
9,176 KB
testcase_24 AC 241 ms
8,512 KB
testcase_25 AC 237 ms
8,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0