結果
| 問題 | No.3746 Swap and LIS |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-25 21:36:28 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 57 ms / 2,000 ms |
| + 463µs | |
| コード長 | 896 bytes |
| 記録 | |
| コンパイル時間 | 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 |
ソースコード
#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';
}
}