結果
| 問題 |
No.953 席
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-12-14 22:53:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,579 bytes |
| コンパイル時間 | 905 ms |
| コンパイル使用メモリ | 82,880 KB |
| 実行使用メモリ | 7,936 KB |
| 最終ジャッジ日時 | 2024-07-02 18:10:07 |
| 合計ジャッジ時間 | 8,090 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | AC * 9 WA * 16 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
7 | main()
| ^~~~
ソースコード
#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;
}
}
}
}