社区讨论
萌新第一天学c艹 , 大神求调(悬冠*1)
P1816忠诚参与者 10已保存回复 35
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 35 条
- 当前快照
- 1 份
- 快照标识符
- @lo1rq5w7
- 此快照首次捕获于
- 2023/10/23 01:54 2 年前
- 此快照最后确认于
- 2023/11/03 02:31 2 年前
优先队列,但是2T 大佬求调```cpp
#include<bits/stdc++.h>
using namespace std;
struct cxk{
int zhi,wei;
bool operator < (const cxk&b) const
{
return zhi > b.zhi;
}
};
int n,k,m;
priority_queue q;
queue q1;
cxk op,ba;
int a[1000005];
int main(){
cin>>m>>n;
for(int i=1;i<=m;i++){
cin>>a[i];
q.push({a[i],i});
}
for(int k=1,x,y;k<=n;k++){
cin>>x>>y;
while(q.top().wei<x||q.top().wei>y){
q1.push(q.top());
q.pop();
}
cout<<q.top().zhi<<" ";
while(!q1.empty()){
q.push(q1.front());
q1.pop();
}
}
CPPreturn 0;
}
CPP回复
共 35 条回复,欢迎继续交流。
正在加载回复...