結果

問題 No.3746 Swap and LIS
コンテスト
ユーザー t98slider
提出日時 2026-09-25 21:36:28
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 57 ms / 2,000 ms
+ 463µs
コード長 896 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,868 ms
コンパイル使用メモリ 339,424 KB
実行使用メモリ 9,900 KB
最終ジャッジ日時 2026-09-25 21:36:35
合計ジャッジ時間 5,857 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while (T--) {
        int N;
        cin >> N;
        vector<int> A(N), B(N);
        for (auto &x : A) cin >> x;
        for (auto &x : B) cin >> x;
        vector<int> a, b;
        auto insert = [&](int x) {
            auto it = lower_bound(a.begin(), a.end(), x);
            if (it == a.end()) {
                a.push_back(x);
                return;
            }
            int y = *it;
            *it = x;
            auto jt = lower_bound(b.begin(), b.end(), y);
            if (jt == b.end()) b.push_back(y);
            else *jt = y;
        };
        for (int i = 0; i < N; i++) {
            insert(max(A[i], B[i]));
            insert(min(A[i], B[i]));
        }
        cout << a.size() + b.size() << '\n';
    }
}
0