結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 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,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,948 KB
testcase_11 WA -
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 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,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 1 ms
6,940 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 176 ms
12,800 KB
testcase_32 AC 259 ms
16,512 KB
testcase_33 AC 149 ms
12,160 KB
testcase_34 AC 102 ms
8,704 KB
testcase_35 AC 191 ms
14,336 KB
testcase_36 AC 186 ms
12,800 KB
testcase_37 AC 276 ms
17,280 KB
testcase_38 AC 186 ms
13,056 KB
testcase_39 AC 123 ms
9,984 KB
testcase_40 AC 90 ms
8,960 KB
testcase_41 AC 125 ms
10,368 KB
testcase_42 AC 353 ms
22,016 KB
testcase_43 AC 185 ms
13,312 KB
testcase_44 RE -
testcase_45 AC 305 ms
20,224 KB
testcase_46 AC 408 ms
23,424 KB
testcase_47 AC 233 ms
15,872 KB
testcase_48 AC 370 ms
24,064 KB
testcase_49 AC 325 ms
19,200 KB
testcase_50 AC 319 ms
22,528 KB
testcase_51 AC 566 ms
29,440 KB
testcase_52 AC 148 ms
12,544 KB
testcase_53 AC 409 ms
23,936 KB
testcase_54 AC 545 ms
31,232 KB
testcase_55 AC 393 ms
25,216 KB
testcase_56 AC 335 ms
21,632 KB
testcase_57 AC 683 ms
32,896 KB
testcase_58 AC 683 ms
32,896 KB
testcase_59 AC 693 ms
32,896 KB
testcase_60 AC 687 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);
        people.erase(itr);
        swap(x, y);
      }
      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