結果

問題 No.2422 regisys?
ユーザー a01sa01toa01sa01to
提出日時 2023-08-12 15:17:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,588 bytes
コンパイル時間 2,295 ms
コンパイル使用メモリ 201,784 KB
最終ジャッジ日時 2025-02-16 06:01:39
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 59 WA * 1 RE * 1
権限があれば一括ダウンロードができます

ソースコード

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