結果
| 問題 | No.3746 Swap and LIS |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-25 21:53:55 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 58 ms / 2,000 ms |
| + 296µs | |
| コード長 | 955 bytes |
| 記録 | |
| コンパイル時間 | 1,334 ms |
| コンパイル使用メモリ | 215,616 KB |
| 実行使用メモリ | 9,868 KB |
| 最終ジャッジ日時 | 2026-09-25 21:54:01 |
| 合計ジャッジ時間 | 5,701 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int T; cin >> T;
while(T--){
int N; cin >> N;
vector<int> A(N),B(N);
for(auto &a : A) cin >> a;
for(auto &a : B) cin >> a;
vector<int> dp1(N+1,1001001001),dp2(N+1,1001001001);
auto add = [&](int x) -> void {
int pos = lower_bound(dp1.begin(),dp1.end(),x)-dp1.begin();
if(dp1.at(pos) != 1001001001){
int pos2 = lower_bound(dp2.begin(),dp2.end(),dp1.at(pos))-dp2.begin();
dp2.at(pos2) = dp1.at(pos);
}
dp1.at(pos) = x;
};
for(int i=0; i<N; i++) add(max(A.at(i),B.at(i))),add(min(A.at(i),B.at(i)));
int answer = 0;
for(auto d : dp1) if(d != 1001001001) answer++;
for(auto d : dp2) if(d != 1001001001) answer++;
cout << answer << "\n";
}
}