結果

問題 No.110 しましまピラミッド
ユーザー a01sa01toa01sa01to
提出日時 2025-01-25 00:26:18
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 967 bytes
コンパイル時間 3,393 ms
コンパイル使用メモリ 279,792 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-01-25 00:26:23
合計ジャッジ時間 4,818 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  int n, m;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  cin >> m;
  vector<int> b(m);
  rep(i, m) cin >> b[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int ans = 0;
  rep(_, 2) {
    // _ == 0 : 白から, 1 : 黒から
    int now = (_ ? b[0] : a[0]), cnt = 1;
    while (true) {
      if (cnt % 2 != _) {
        // 黒
        auto it = upper_bound(b.begin(), b.end(), now);
        if (it == b.end()) break;
        now = *it;
        cnt++;
      }
      else {
        // 白
        auto it = upper_bound(a.begin(), a.end(), now);
        if (it == a.end()) break;
        now = *it;
        cnt++;
      }
    }
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}
0