結果

問題 No.110 しましまピラミッド
ユーザー jajagacchijajagacchi
提出日時 2016-12-31 14:02:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 817 bytes
コンパイル時間 512 ms
コンパイル使用メモリ 63,864 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 03:56:52
合計ジャッジ時間 1,801 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>

int max_height(int *p , int *q , int Np , int Nq)
{
	int h = 1;
	bool flag = true;
	int ip = 0, iq = 0;
	while(flag)
	{
		flag = false;
		for(int i=iq;i<Nq;i++)
		{
			if(q[i]<p[ip])
			{
				h++;
				iq = i;
				ip++;
				std::swap(p,q);
				std::swap(ip,iq);
				std::swap(Np,Nq);
				flag = true;
				break;
			}
		}
	}
	return h;
}

int main()
{
	int Nw; std::cin >> Nw;
	int *W = new int[Nw];
	for(int n=0;n<Nw;n++)
	{
		std::cin >> W[n];
	}
	int Nb; std::cin >> Nb;
	int *B = new int[Nb];
	for(int n=0;n<Nb;n++)
	{
		std::cin >> B[n];
	}
 	std::sort(W , W+Nw , std::greater<int>());
 	std::sort(B , B+Nb , std::greater<int>());

	int h = std::max(max_height(W,B,Nw,Nb) , max_height(B,W,Nb,Nw));
	std::cout << h;

	delete[] W;
	delete[] B;
	return 0;
}
0