Pagini recente » Cod sursa (job #2812102) | Cod sursa (job #2586274) | Cod sursa (job #1223619) | Cod sursa (job #316990) | Cod sursa (job #1776122)
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n,m,x,y;
vector<int>::iterator it;
cin>>n;
vector<int> V(n+1);
for(int i=1; i<=n; i+=1)
{
cin>>x;
V[i]=x;
}
cin>>m;
for(int i=0; i<m; i+=1)
{
cin>>x>>y;
if(x==0)
{
it = upper_bound(V.begin()+1,V.end(),y);
if(it!=V.end())
cout<<(it-V.begin()-1)<<'\n';
else
cout<<-1<<'\n';
}
if(x==1)
{
it = lower_bound(V.begin()+1,V.end(),y+1);
cout<<(it-V.begin()-1)<<'\n';
}
if(x==2)
{
it = upper_bound(V.begin()+1,V.end(),y-1);
Q.push(it-V.begin())<<'\n';
}
}
return 0;
}