結果

問題 No.110 しましまピラミッド
ユーザー kotatsugame
提出日時 2017-08-10 04:48:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 511 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 75,028 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-12 01:31:35
合計ジャッジ時間 1,675 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21 WA * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<queue>
using namespace std;
priority_queue<int>W,B;
int n,a,now,cnt;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a,W.push(a);
	cin>>n;
	for(int i=0;i<n;i++)cin>>a,B.push(a);
	bool f=W.top()>B.top();
	now=114514;
	while(f?!W.empty():!B.empty())
	{
		if(f)
		{
			while(!W.empty()&&W.top()>=now)W.pop();
			if(!W.empty())now=W.top(),W.pop(),cnt++;
		}
		else
		{
			while(!B.empty()&&B.top()>=now)B.pop();
			if(!B.empty())now=B.top(),B.pop(),cnt++;
		}
		f=!f;
	}
	cout<<cnt<<endl;
}
0