結果

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

ソースコード

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