Pagini recente » Cod sursa (job #512171) | Cod sursa (job #1792410) | Cod sursa (job #1367407) | Cod sursa (job #1793177) | Cod sursa (job #2049911)
#include <fstream>
#include <algorithm>
using namespace std;
ifstream f("cautbin.in");
ofstream g("cautbin.out");
int n,i,m,x,x0,v[1000];
int main()
{f>>n;
for(i=1;i<=n;i++)f>>v[i];
f>>m;
for(i=1;i<=m;i++)
{
f>>x0>>x;
if(x0==0)
{
g<<upper_bound(v+1,v+n+1,x)-v-1<<'\n';
}
if(x0==1)
{
g<<upper_bound(v+1,v+n+1,x)-v-1<<'\n';
}
if(x0==2)
{
g<<lower_bound(v+1,v+n+1,x)-v<<'\n';
}
}
return 0;
}