結果
問題 | No.110 しましまピラミッド |
ユーザー | Mcpu3 |
提出日時 | 2019-03-15 15:51:52 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 2,083 bytes |
コンパイル時間 | 796 ms |
コンパイル使用メモリ | 77,104 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-08-30 04:09:05 |
合計ジャッジ時間 | 1,960 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 1 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,376 KB |
testcase_12 | AC | 2 ms
4,376 KB |
testcase_13 | AC | 1 ms
4,376 KB |
testcase_14 | AC | 1 ms
4,376 KB |
testcase_15 | AC | 2 ms
4,384 KB |
testcase_16 | AC | 2 ms
4,376 KB |
testcase_17 | AC | 2 ms
4,380 KB |
testcase_18 | AC | 2 ms
4,380 KB |
testcase_19 | AC | 1 ms
4,376 KB |
testcase_20 | AC | 2 ms
4,380 KB |
testcase_21 | AC | 1 ms
4,380 KB |
testcase_22 | AC | 1 ms
4,380 KB |
testcase_23 | AC | 1 ms
4,376 KB |
testcase_24 | AC | 2 ms
4,380 KB |
testcase_25 | AC | 2 ms
4,376 KB |
testcase_26 | AC | 2 ms
4,376 KB |
testcase_27 | AC | 2 ms
4,380 KB |
testcase_28 | AC | 2 ms
4,376 KB |
testcase_29 | AC | 1 ms
4,376 KB |
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; // algorithm, vector struct binarySearch { /// <summary>key未満の要素を探索します</summary> /// <returns>要素のindexが返されます</returns> template<typename T> static int formerLower(vector<T>& a, T key) { return lower_bound(a.begin(), a.end(), key) - a.begin() - 1; } /// <summary>key以下の要素を探索します</summary> /// <returns>要素のindexが返されます</returns> template<typename T> static int formerUpper(vector<T>& a, T key) { return upper_bound(a.begin(), a.end(), key) - a.begin() - 1; } /// <summary>key以上の要素を探索します</summary> /// <returns>要素のindexが返されます</returns> template<typename T> static int latterLower(vector<T>& a, T key) { return lower_bound(a.begin(), a.end(), key) - a.begin(); } /// <summary>keyより大きい要素を探索します</summary> /// <returns>要素のindexが返されます</returns> template<typename T> static int latterUpper(vector<T>& a, T key) { return upper_bound(a.begin(), a.end(), key) - a.begin(); } }; int main() { int Nw; cin >> Nw; vector<int> W(Nw); for (int& i : W) cin >> i; W.push_back(0); sort(W.begin(), W.end()); int Nb; cin >> Nb; vector<int> B(Nb); for (int& i : B) cin >> i; B.push_back(0); sort(B.begin(), B.end()); bool tmp1 = false; int sum1 = 0, tmp2 = W[W.size() - 1]; while (true) { ++sum1; if (tmp1) { tmp2 = W[binarySearch::formerLower(W, tmp2)]; if (tmp2 == 0) break; tmp1 = false; } else { tmp2 = B[binarySearch::formerLower(B, tmp2)]; if (tmp2 == 0) break; tmp1 = true; } } int sum2 = 0; tmp1 = true; tmp2 = B[B.size() - 1]; while (true) { ++sum2; if (tmp1) { tmp2 = W[binarySearch::formerLower(W, tmp2)]; if (tmp2 == 0) break; tmp1 = false; } else { tmp2 = B[binarySearch::formerLower(B, tmp2)]; if (tmp2 == 0) break; tmp1 = true; } } cout << max(sum1, sum2); }