結果

問題 No.110 しましまピラミッド
ユーザー hotpepsi
提出日時 2015-08-31 01:37:00
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 772 bytes
コンパイル時間 645 ms
コンパイル使用メモリ 61,496 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-31 11:12:04
合計ジャッジ時間 1,655 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>
#include <numeric>

using namespace std;

int main(int argc, char *argv[])
{
	int N[2];
	int W[2][1000] = {};
	cin >> N[0];
	for (int i = 0; i < N[0]; ++i) {
		cin >> W[0][i];
	}
	cin >> N[1];
	for (int i = 0; i < N[1]; ++i) {
		cin >> W[1][i];
	}
	sort(W[0], W[0] + N[0]);
	sort(W[1], W[1] + N[1]);
	int ans = 1;
	for (int i = 0; i < 2; ++i) {
		int cnt = 0;
		int len = 0;
		int index[2] = { 0, 0 };
		int next = i;
		while (1) {
			for (; index[next] < N[next]; ++index[next]) {
				if (W[next][index[next]] > len) {
					break;
				}
			}
			if (index[next] >= N[next]) {
				break;
			}
			++cnt;
			len = W[next][index[next]];
			next ^= 1;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}
0