社区讨论
28pts 求条
P1801黑匣子参与者 2已保存回复 6
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 6 条
- 当前快照
- 1 份
- 快照标识符
- @mlhz557x
- 此快照首次捕获于
- 2026/02/11 19:56 上周
- 此快照最后确认于
- 2026/02/13 19:10 6 天前
CPP
#include<bits/stdc++.h>
using namespace std;
priority_queue<int>mx;
priority_queue<int,vector<int>,greater<int>>mi;
int m,n,a[200005],u[200005];
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>m>>n;
for(int i=1;i<=m;i++)cin>>a[i];
for(int i=1;i<=n;i++)cin>>u[i];
int j=1;
for(int i=1;i<=n;i++){
while(j<=u[i]){
mx.push(a[j]);
if(mx.size()>i){
mi.push(mx.top());
mx.pop();
}
j++;
}
cout<<mx.top()<<"\n";
}
return 0;
}
回复
共 6 条回复,欢迎继续交流。
正在加载回复...