結果

問題 No.953 席
ユーザー kotatsugamekotatsugame
提出日時 2019-12-14 22:52:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,581 bytes
コンパイル時間 925 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 7,384 KB
最終ジャッジ日時 2023-09-15 15:27:32
合計ジャッジ時間 8,481 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 232 ms
4,376 KB
testcase_03 AC 228 ms
4,376 KB
testcase_04 AC 224 ms
4,380 KB
testcase_05 AC 225 ms
4,376 KB
testcase_06 AC 229 ms
4,376 KB
testcase_07 AC 153 ms
7,384 KB
testcase_08 AC 239 ms
5,868 KB
testcase_09 AC 125 ms
6,536 KB
testcase_10 AC 51 ms
4,376 KB
testcase_11 AC 175 ms
5,052 KB
testcase_12 AC 241 ms
4,620 KB
testcase_13 AC 251 ms
5,740 KB
testcase_14 AC 231 ms
4,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 233 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 255 ms
5,996 KB
testcase_26 AC 217 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<queue>
using namespace std;
bool exs[1<<17];
int N,K1,K2;
int dis[1<<17];
main()
{
	cin>>N>>K1>>K2;
	if(K1<K2)
	{
		int i=-1;
		while(1<=K1&&K2<=N)
		{
			dis[K1--]=i--;
			dis[K2++]=i--;
		}
		while(1<=K1)dis[K1--]=i--;
		while(K2<=N)dis[K2++]=i--;
	}
	else
	{
		int i=-1;
		while(1<=K2&&K1<=N)
		{
			dis[K1++]=i--;
			dis[K2--]=i--;
		}
		while(K1<=N)dis[K1++]=i--;
		while(1<=K2)dis[K2--]=i--;
	}
	int Q;cin>>Q;
	priority_queue<pair<int,int> >P1,P2;
	for(int i=1;i<=N;i++)
	{
		P1.push(make_pair(dis[i],i));
	}
	priority_queue<pair<long,int> >X;
	for(int ccc=0;ccc<Q;ccc++)
	{
		long A,B;cin>>A>>B;
		while(!X.empty()&&(-X.top().first<=A||X.size()>=N))
		{
			int id=X.top().second;
			if(-X.top().first>A)A=-X.top().first;
			X.pop();
			exs[id]=false;
			for(int j=id-1;j<=id+1;j++)
			{
				if(j<1||j>N)continue;
				if(!exs[j-1]&&!exs[j]&&!exs[j+1])
				{
					P1.push(make_pair(dis[j],j));
				}
				else if(j==id)P2.push(make_pair(dis[j],j));
			}
		}
		bool flag=true;
		while(!P1.empty())
		{
			int id=P1.top().second;P1.pop();
			if(exs[id])continue;
			else if(exs[id-1]||exs[id+1])
			{
				P2.push(make_pair(dis[id],id));
				continue;
			}
			flag=false;
			cout<<id<<endl;
			X.push(make_pair(-A-B,id));
			exs[id]=true;
			if(1<=id-1)P2.push(make_pair(dis[id-1],id-1));
			if(id+1<=N)P2.push(make_pair(dis[id+1],id+1));
			break;
		}
		if(flag)
		{
			while(!P2.empty())
			{
				int id=P2.top().second;P2.pop();
				if(exs[id])continue;
				cout<<id<<endl;
				X.push(make_pair(-A-B,id));
				exs[id]=true;
				break;
			}
		}
	}
}
0