結果
問題 | No.110 しましまピラミッド |
ユーザー |
![]() |
提出日時 | 2015-05-13 22:31:26 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 904 bytes |
コンパイル時間 | 847 ms |
コンパイル使用メモリ | 67,680 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-31 11:08:51 |
合計ジャッジ時間 | 1,589 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:26:45: warning: narrowing conversion of ‘(c[0].std::vector<int>::size() - 1)’ from ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} to ‘int’ [-Wnarrowing] 26 | int next[2] = { c[0].size() - 1, c[1].size() - 1 }; | ~~~~~~~~~~~~^~~ main.cpp:26:62: warning: narrowing conversion of ‘(c[1].std::vector<int>::size() - 1)’ from ‘std::vector<int>::size_type’ {aka ‘long unsigned int’} to ‘int’ [-Wnarrowing] 26 | int next[2] = { c[0].size() - 1, c[1].size() - 1 }; | ~~~~~~~~~~~~^~~
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <limits> using namespace std; int main() { int n; vector<int> c[2]; cin >> n; c[0].resize(n); for (int i = 0; i < n; ++i) { cin >> c[0][i]; } cin >> n; c[1].resize(n); for (int i = 0; i < n; ++i) { cin >> c[1][i]; } sort(c[0].begin(), c[0].end()); sort(c[1].begin(), c[1].end()); int maxHeight = 0; for (int startColor = 0; startColor <= 1; ++startColor) { int color = startColor; int next[2] = { c[0].size() - 1, c[1].size() - 1 }; int length = numeric_limits<int>::max(); int height = 0; for (;;) { while (next[color] >= 0 && c[color][next[color]] >= length) { --next[color]; } if (next[color] < 0) { break; } length = c[color][next[color]]; --next[color]; ++height; color = 1 - color; } maxHeight = max(maxHeight, height); } cout << maxHeight << endl; return 0; }