社区讨论
100分,但 Subtask #1 TLE了,求调
P1816忠诚参与者 4已保存回复 5
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 5 条
- 当前快照
- 1 份
- 快照标识符
- @mdgs22w9
- 此快照首次捕获于
- 2025/07/24 10:32 7 个月前
- 此快照最后确认于
- 2025/11/04 03:50 4 个月前
CPP
#include <bits/stdc++.h>
using namespace std;
int n,m,d,f[1000011],l[1000011];
priority_queue < pair < int,int > ,vector < pair < int,int > > ,greater < pair<int,int> > > q;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>m>>n;
for(int i=1;i<=m;i++){
cin>>d;
q.push(make_pair(d,i));
}
for(int i=1;i<=m;i++){
f[i]=q.top().first;
l[i]=q.top().second;
q.pop();
}
for(int i=1;i<=n;i++){
int a,b;
cin>>a>>b;
for(int j=1;j<=m;j++){
if(l[j]>=a&&l[j]<=b){
cout<<f[j]<<" ";
break;
}
}
}
return 0;
}
回复
共 5 条回复,欢迎继续交流。
正在加载回复...