結果

問題 No.110 しましまピラミッド
ユーザー rodearodea
提出日時 2018-01-13 13:43:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 779 bytes
コンパイル時間 615 ms
コンパイル使用メモリ 72,676 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 15:35:18
合計ジャッジ時間 3,047 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 WA -
testcase_11 AC 1 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,380 KB
testcase_15 WA -
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 WA -
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include <functional>
using namespace std;

int solve(int nw, int w[11], int nb, int b[11])
{
	int i, j = 1, count = 1, k = 1, l = 1;

	while (1)
	{
		for (i = k; i <= nb; i++)
		{
			if (w[j] > b[i])
			{
				k = i + 1;
				count++;
				break;
			}
		}

		for (j = l; j <= nw; j++)
		{
			if (b[i] > w[j])
			{
				l = j + 1;
				count++;
				break;
			}
		}

		if (i >= nb && j >= nw) break;
	}

	return count;
}

int main()
{
	int nw, w[11], nb, b[11];

	cin >> nw;

	for (int i = 1; i <= nw; i++)
	{
		cin >> w[i];
	}

	sort(w + 1, w + nw + 1, greater<int>());

	cin >> nb;

	for (int i = 1; i <= nb; i++)
	{
		cin >> b[i];
	}

	sort(b + 1, b + nb + 1, greater<int>());

	cout << max(solve(nw, w, nb, b), solve(nb, b, nw, w)) << endl;
}
0