Pair in c++

Revision ru1, by Dias_best, 2024-10-11 16:09:21

include <bits/stdc++.h>

using namespace std; using ll=long long; int main() { int n,q; cin>>n>>q; pair<int,int>a[n+1]; for(int i=1;i<=n;i++) { cin>>a[i].first; a[i].second=i; } sort(a+1,a+1+n); while(q--) { int t; cin>>t; if(t==1) cout<<a[1].second; else cout<<a[n].second; cout<<'\n'; } }

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
ru1 Russian Dias_best 2024-10-11 16:09:21 393 Первая редакция (опубликовано)