社区讨论
蒟蒻求助qwq
P5462X龙珠参与者 1已保存回复 0
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mi86k88h
- 此快照首次捕获于
- 2025/11/21 09:27 4 个月前
- 此快照最后确认于
- 2025/11/21 09:27 4 个月前
一个也过不了。。。。。。
CPP#include<bits/stdc++.h>
using namespace std;
struct b22
{
int num,p;
bool operator < (const b22& x) const
{
return num<x.num;
}
};
int main()
{
int n;
cin>>n;
int ball[n+5],last=n;
priority_queue<b22> q;
bool out[n+5];
memset(out,false,sizeof(out));
for(int i=1;i<=n;i++)
{
cin>>ball[i];
q.push(b22{ball[i],i});
}
while(!q.empty()&&last>0)
{
int np=q.top().p;
q.pop();
if(out[np]||np>=last)
continue;
for(int i=np+1;i<=n;i++)
if(!out[i])
{
cout<<ball[np]<<' '<<ball[np+1]<<' ';
break;
}
out[np]=out[np+1]=true;
if(np+1==last)
last-=2;
}
return 0;
}
回复
共 0 条回复,欢迎继续交流。
正在加载回复...