1.C-李渊的准备_第十四届南京工程学院程序设计及应用竞赛校外同步赛 (nowcoder.com)
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+6;
const int inf=0x3f3f3f3f;
typedef pair<int,int> pii;
bool cmp(pii x,pii y)
{
return x.first>y.first;
}
void solve()
{
int n,t,q;
cin>>n>>t>>q;
vector<pii>ve(N);
for(int i=0;i<n;i++)
{
cin>>ve[i].first;
ve[i].second=i+1;
}
sort(ve.begin(),ve.end(),cmp);
while(t--)
{
bool f=0;
int l,r,max1=-inf;
cin>>l>>r;
for(auto it:ve)
{
if(it.second>=l&&it.second<=r)
{
if(it.first>=q)
{
f=1;
}
max1=it.first;
break;
}
}
cout<<max1<<' ';
if(f)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
int t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}
标签:pii,ve,int,31,max1,倒计时,second,first
From: https://blog.csdn.net/fkuelntxgt/article/details/136687630