結果

問題 No.2422 regisys?
ユーザー simansiman
提出日時 2023-08-28 21:47:27
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 330 ms / 2,000 ms
コード長 1,832 bytes
コンパイル時間 5,835 ms
コンパイル使用メモリ 107,552 KB
実行使用メモリ 10,528 KB
最終ジャッジ日時 2023-08-28 21:47:45
合計ジャッジ時間 17,208 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,384 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 104 ms
5,628 KB
testcase_32 AC 152 ms
5,288 KB
testcase_33 AC 95 ms
5,804 KB
testcase_34 AC 65 ms
4,384 KB
testcase_35 AC 117 ms
6,772 KB
testcase_36 AC 110 ms
4,764 KB
testcase_37 AC 159 ms
5,668 KB
testcase_38 AC 118 ms
4,384 KB
testcase_39 AC 82 ms
4,376 KB
testcase_40 AC 62 ms
5,044 KB
testcase_41 AC 80 ms
4,376 KB
testcase_42 AC 201 ms
9,864 KB
testcase_43 AC 111 ms
5,028 KB
testcase_44 AC 218 ms
9,748 KB
testcase_45 AC 184 ms
8,140 KB
testcase_46 AC 218 ms
9,624 KB
testcase_47 AC 135 ms
6,076 KB
testcase_48 AC 222 ms
10,528 KB
testcase_49 AC 174 ms
7,128 KB
testcase_50 AC 203 ms
10,308 KB
testcase_51 AC 284 ms
8,500 KB
testcase_52 AC 96 ms
6,296 KB
testcase_53 AC 221 ms
9,420 KB
testcase_54 AC 299 ms
10,304 KB
testcase_55 AC 221 ms
9,420 KB
testcase_56 AC 203 ms
7,040 KB
testcase_57 AC 322 ms
9,068 KB
testcase_58 AC 321 ms
9,064 KB
testcase_59 AC 322 ms
9,120 KB
testcase_60 AC 330 ms
9,064 KB
testcase_61 AC 1 ms
4,376 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 {
  int i;
  int value;

  Node(int i = -1, int value = -1) {
    this->i = i;
    this->value = value;
  }

  bool operator>(const Node &n) const {
    return value > n.value;
  }
};

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> B[i];
  }

  vector<int> C[2];
  for (int i = 0; i < M; ++i) {
    int t, c;
    cin >> t >> c;
    C[t].push_back(c);
  }

  sort(C[0].begin(), C[0].end());
  priority_queue <Node, vector<Node>, greater<Node>> pque_a;
  bool checked[N];
  memset(checked, false, sizeof(checked));
  int cnt = 0;

  for (int i = 0; i < N; ++i) {
    pque_a.push(Node(i, A[i]));
  }

  priority_queue <Node, vector<Node>, greater<Node>> stock;
  for (int c : C[0]) {
    while (not pque_a.empty() && pque_a.top().value <= c) {
      int i = pque_a.top().i;
      pque_a.pop();

      stock.push(Node(i, -B[i]));
    }

    if (not stock.empty()) {
      Node n = stock.top();
      stock.pop();
      checked[n.i] = true;
      cnt++;
    }
  }

  sort(C[1].begin(), C[1].end());
  reverse(C[1].begin(), C[1].end());
  priority_queue <Node, vector<Node>, greater<Node>> pque_b;
  for (int i = 0; i < N; ++i) {
    if (not checked[i]) {
      pque_b.push(Node(i, -B[i]));
    }
  }

  for (int c : C[1]) {
    while (not pque_b.empty()) {
      int i = pque_b.top().i;
      pque_b.pop();

      if (B[i] <= c) {
        checked[i] = true;
        cnt++;
        break;
      }
    }
  }

  cout << N - cnt << endl;

  return 0;
}
0