結果
| 問題 |
No.110 しましまピラミッド
|
| コンテスト | |
| ユーザー |
Tatsu_mr
|
| 提出日時 | 2024-10-26 17:16:40 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,564 bytes |
| コンパイル時間 | 3,576 ms |
| コンパイル使用メモリ | 252,148 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-26 17:16:45 |
| 合計ジャッジ時間 | 4,820 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
#define For(i, a, b) for(long long i = a; i < b; i++)
#define rep(i, n) For(i, 0, n)
#define rFor(i, a, b) for(long long i = a; i >= b; i--)
#define ALL(v) (v).begin(), (v).end()
#define rALL(v) (v).rbegin(), (v).rend()
using namespace std;
using lint = long long;
using ld = long double;
int INF = 2000000000;
lint LINF = 1000000000000000000;
int main() {
int n;
cin >> n;
multiset<int> a;
rep(i, n) {
int x;
cin >> x;
a.insert(x);
}
int m;
cin >> m;
multiset<int> b;
rep(i, m) {
int x;
cin >> x;
b.insert(x);
}
auto f = [](multiset<int> s, multiset<int> t) {
int now = 0;
vector<int> v = {-1};
while (true) {
bool add = false;
if (now == 0) {
auto it = s.upper_bound(v.back());
if (it != s.end()) {
int x = *it;
v.emplace_back(x);
s.erase(s.find(x));
add = true;
now ^= 1;
}
} else {
auto it = t.upper_bound(v.back());
if (it != t.end()) {
int x = *it;
v.emplace_back(x);
t.erase(t.find(x));
add = true;
now ^= 1;
}
}
if (!add) {
break;
}
}
return (int)v.size() - 1;
};
cout << max(f(a, b), f(b, a)) << endl;
}
Tatsu_mr