Pagini recente » Cod sursa (job #1515134) | Cod sursa (job #616405) | Cod sursa (job #1402189) | Cod sursa (job #2392634) | Cod sursa (job #1708599)
#include <cstdio>
int v[100005], c, k, n;
using namespace std;
inline void cb1( )
{
int pas=1<<16, i=0;
while( pas!=0 )
{
if( i+pas<=n && v[i+pas]<=k )
i+=pas;
pas/=2;
}
printf( "%d\n", i );
}
inline void cb2( )
{
int pas=1<<16, i=0;
while( pas!=0 )
{
if( i+pas<=n && v[i+pas]<k )
i+=pas;
pas/=2;
}
printf( "%d\n", i+1 );
}
int main()
{
freopen( "cautbin.in", "r", stdin );
freopen( "cautbin.out", "w", stdout );
int i, m;
scanf( "%d", &n );
for( i=1;i<=n;i++ )
scanf( "%d", &v[i] );
scanf( "%d", &m );
for( i=1;i<=m;i++ )
{
scanf( "%d%d", &c, &k );
if( c==0 || c==1 )
cb1();
else
cb2();
}
return 0;
}