結果

問題 No.110 しましまピラミッド
ユーザー fiord
提出日時 2015-06-23 23:47:03
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 813 bytes
コンパイル時間 531 ms
コンパイル使用メモリ 64,580 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-07 17:13:40
合計ジャッジ時間 1,545 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n[2];	cin>>n[0];
	vector<int> w(n[0]);
	for(int i=0;i<n[0];i++)	cin>>w[i];
	sort(w.begin(),w.end());
	cin>>n[1];
	vector<int> b(n[1]);
	for(int i=0;i<n[1];i++)	cin>>b[i];
	sort(b.begin(),b.end());
	int scr[2]={0,0},temp=0,cnt[2];
	for(int i=0;i<2;i++){
		temp=0;	cnt[0]=0;	cnt[1]=0;
		int turn=i;
		while(1){
			bool end=true;
			while(cnt[turn]<n[turn]){
				if(turn==0&&w[cnt[turn]]>temp){
					scr[i]++;
					end=false;
					temp=w[cnt[turn]];
					cnt[turn]++;
					break;
				}
				else if(b[cnt[turn]]>temp){
					scr[i]++;
					end=false;
					temp=b[cnt[turn]];
					cnt[turn]++;
					break;
				}
				else cnt[turn]++;
			}
			if(end)	break;
			turn^=1;
		}
	}
	cout<<max(scr[0],scr[1])<<endl;
	return 0;
}
0