You are on page 1of 1

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyApp //cmiljaaa


{
internal class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] a = new int[n];
for (int i = 0; i < n; i++)
{
a[i] = int.Parse(Console.ReadLine());
}
int m = int.Parse(Console.ReadLine());
for (int i = 0; i < m; i++)
{
int x = int.Parse(Console.ReadLine());
int l = 0;
int d = n - 1;
while (l<=d)
{
int s = l + ((d - l) / 2);
if (a[s] >= x)
l = s + 1;
else if (a[s] < x)
d = s - 1;
}
Console.WriteLine(l);
}
}
}
}

You might also like