結果
問題 |
No.110 しましまピラミッド
|
ユーザー |
|
提出日時 | 2022-09-29 21:46:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 924 bytes |
コンパイル時間 | 2,050 ms |
コンパイル使用メモリ | 199,728 KB |
最終ジャッジ日時 | 2025-02-07 18:26:23 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int Nw; cin >> Nw; vector<int> W(Nw); rep(i,Nw) cin >> W[i]; sort(W.begin(), W.end()); int Nb; cin >> Nb; vector<int> B(Nb); rep(i,Nb) cin >> B[i]; sort(B.begin(), B.end()); auto f = [&](vector<int> A, vector<int> B) { vector<int> ans = {int(1e9)}; while(true) { while(!A.empty() && ans.back() <= A.back()) A.pop_back(); if(A.empty()) break; ans.push_back(A.back()); A.pop_back(); while(!B.empty() && ans.back() <= B.back()) B.pop_back(); if(B.empty()) break; ans.push_back(B.back()); B.pop_back(); } return int(ans.size()) - 1; }; cout << max(f(W, B), f(B, W)) << endl; }