結果
問題 |
No.110 しましまピラミッド
|
ユーザー |
![]() |
提出日時 | 2023-10-23 09:57:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,840 bytes |
コンパイル時間 | 2,248 ms |
コンパイル使用メモリ | 198,608 KB |
最終ジャッジ日時 | 2025-02-17 13:14:12 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 25 WA * 1 |
ソースコード
#include <bits/stdc++.h> #include<iostream> #include<iomanip> #include<string> #include<algorithm> #include<vector> #include<set> #include<list> #include<queue> #include<math.h> #include<bitset> using ll = long long; using namespace std; int main(){ int nw, nb, pw = 0, pb = 0, answ = 0, ansb = 0; cin >> nw; vector<int> w(nw); for (int i = 0; i < nw; i++) cin >> w[i]; cin >> nb; vector<int> b(nb); for (int i = 0; i < nb; i++) cin >> b[i]; sort(w.begin(), w.end(), greater()); sort(b.begin(), b.end(), greater()); // black first -> white を探索 if (nb) ansb++; for (int i = pw; i < nw; i++){ bool found = false; if (w[i] < b[pb]){ ansb++; pw = i+1; pb++; found = true; if (pb == nb) break; } if (found){ found = false; for (int j = pb; j < nb; j ++){ if (w[i] > b[j]){ ansb++; pb = j; found = true; break; } } if (pb == nb) break; } if (pb == nb) break; } pb = 0; pw = 0; if (nw) answ++; for (int i = pb; i < nb; i++){ bool found = false; if (b[i] < w[pw]){ answ++; pb = i+1; pw++; found = true; if (pw == nw) break; } if (found){ found = false; for (int j = pw; j < nw; j ++){ if (b[i] > w[j]){ answ++; pw = j; found = true; break; } } if (pw == nw) break; } if (pw == nw) break; } cout << max(answ, ansb) << endl; }