結果

問題 No.2422 regisys?
ユーザー tnakao0123tnakao0123
提出日時 2023-08-21 19:09:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 1,336 bytes
コンパイル時間 2,344 ms
コンパイル使用メモリ 63,692 KB
実行使用メモリ 14,676 KB
最終ジャッジ日時 2023-08-21 19:10:01
合計ジャッジ時間 9,565 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,500 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,384 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 59 ms
6,980 KB
testcase_32 AC 73 ms
5,704 KB
testcase_33 AC 57 ms
7,336 KB
testcase_34 AC 31 ms
4,384 KB
testcase_35 AC 74 ms
8,496 KB
testcase_36 AC 53 ms
4,744 KB
testcase_37 AC 77 ms
6,156 KB
testcase_38 AC 55 ms
4,412 KB
testcase_39 AC 37 ms
4,376 KB
testcase_40 AC 35 ms
5,532 KB
testcase_41 AC 38 ms
4,380 KB
testcase_42 AC 131 ms
12,784 KB
testcase_43 AC 55 ms
5,360 KB
testcase_44 AC 138 ms
12,476 KB
testcase_45 AC 115 ms
11,228 KB
testcase_46 AC 135 ms
12,432 KB
testcase_47 AC 74 ms
6,948 KB
testcase_48 AC 159 ms
14,596 KB
testcase_49 AC 94 ms
7,956 KB
testcase_50 AC 138 ms
14,560 KB
testcase_51 AC 181 ms
11,584 KB
testcase_52 AC 61 ms
7,864 KB
testcase_53 AC 142 ms
11,952 KB
testcase_54 AC 190 ms
14,676 KB
testcase_55 AC 149 ms
13,240 KB
testcase_56 AC 112 ms
9,232 KB
testcase_57 AC 173 ms
11,368 KB
testcase_58 AC 197 ms
11,220 KB
testcase_59 AC 174 ms
11,408 KB
testcase_60 AC 177 ms
11,312 KB
testcase_61 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2422.cc:  No.2422 regisys? - yukicoder
 */

#include<cstdio>
#include<vector>
#include<set>
#include<algorithm>
#include<utility>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_M = 200000;

/* typedef */

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef multiset<int> msi;

/* global variables */

int as[MAX_N], bs[MAX_N];
pii ps[MAX_N];
vi tcs[2];

/* subroutines */

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  for (int i = 0; i < n; i++) scanf("%d", as + i);
  for (int i = 0; i < n; i++) scanf("%d", bs + i);
  for (int i = 0; i < n; i++) ps[i] = pii(as[i], bs[i]);
  sort(ps, ps + n);

  for (int i = 0; i < m; i++) {
    int ti, ci;
    scanf("%d%d", &ti, &ci);
    tcs[ti].push_back(ci);
  }

  vi &cs0 = tcs[0], &cs1 = tcs[1];
  sort(cs0.begin(), cs0.end());
  sort(cs1.begin(), cs1.end());

  msi bcs;
  int s = 0, k = 0;
  for (auto c0: cs0) {
    while (k < n && ps[k].first <= c0) bcs.insert(ps[k++].second);

    if (! bcs.empty()) {
      s++;
      auto sit = bcs.end();
      bcs.erase(--sit);
    }
  }

  while (k < n) bcs.insert(ps[k++].second);

  for (auto c1: cs1) {
    auto sit = bcs.upper_bound(c1);
    if (sit != bcs.begin()) {
      s++;
      bcs.erase(--sit);
    }
  }

  printf("%d\n", n - s);
  return 0;
}
0