結果

問題 No.2422 regisys?
ユーザー a01sa01toa01sa01to
提出日時 2023-08-12 15:17:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,588 bytes
コンパイル時間 2,060 ms
コンパイル使用メモリ 212,096 KB
実行使用メモリ 32,896 KB
最終ジャッジ日時 2024-04-30 08:44:21
合計ジャッジ時間 15,028 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 WA -
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 1 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 1 ms
6,944 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 163 ms
12,928 KB
testcase_32 AC 263 ms
16,640 KB
testcase_33 AC 147 ms
12,160 KB
testcase_34 AC 97 ms
8,704 KB
testcase_35 AC 180 ms
14,208 KB
testcase_36 AC 188 ms
12,876 KB
testcase_37 AC 285 ms
17,408 KB
testcase_38 AC 184 ms
12,928 KB
testcase_39 AC 123 ms
9,856 KB
testcase_40 AC 93 ms
9,088 KB
testcase_41 AC 125 ms
10,496 KB
testcase_42 AC 341 ms
22,016 KB
testcase_43 AC 181 ms
13,312 KB
testcase_44 RE -
testcase_45 AC 309 ms
20,224 KB
testcase_46 AC 399 ms
23,424 KB
testcase_47 AC 234 ms
15,744 KB
testcase_48 AC 426 ms
24,064 KB
testcase_49 AC 331 ms
19,200 KB
testcase_50 AC 350 ms
22,528 KB
testcase_51 AC 567 ms
29,312 KB
testcase_52 AC 149 ms
12,544 KB
testcase_53 AC 422 ms
23,936 KB
testcase_54 AC 561 ms
31,232 KB
testcase_55 AC 408 ms
25,088 KB
testcase_56 AC 349 ms
21,632 KB
testcase_57 AC 720 ms
32,896 KB
testcase_58 AC 715 ms
32,896 KB
testcase_59 AC 675 ms
32,896 KB
testcase_60 AC 670 ms
32,896 KB
testcase_61 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
  #define _GLIBCXX_DEBUG
#else
  #define Debug(...) void(0)
#endif
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  multiset<pair<int, int>> general, mma;
  rep(i, n) {
    general.insert({ a[i], b[i] });
    mma.insert({ b[i], a[i] });
  }
  multiset<pair<int, int>> people;
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    people.insert({ y, x });
  }
  rep(i, m) {
    auto [c, t] = *people.begin();
    auto&& my = (t == 0 ? general : mma);
    auto&& opp = (t == 0 ? mma : general);

    auto itr = my.upper_bound({ c, 2e9 });
    if (itr == my.begin()) {
      people.erase(people.begin());
      continue;
    }
    auto [x, y] = *prev(itr);
    if (x > y) {
      auto itr = people.find({ c, 1 - t });
      if (itr != people.end()) {
        my = (t == 1 ? general : mma);
        opp = (t == 1 ? mma : general);
        t = 1 - t;
        auto itr3 = my.upper_bound({ c, 2e9 });
        if (itr3 == my.begin()) assert(false);
        auto [_x, _y] = *prev(itr3);
        x = _x, y = _y;
        people.erase(itr);
      }
      else {
        people.erase(people.begin());
      }
    }
    else {
      people.erase(people.begin());
    }
    auto itr1 = my.find({ x, y });
    my.erase(itr1);
    auto itr2 = opp.find({ y, x });
    opp.erase(itr2);
  }
  assert(general.size() == mma.size());
  cout << general.size() << endl;
  return 0;
}
0