#include
#include
#include
#define MAX 100000+100
using namespace std;
int erfen(int *arr, int left, int right, int target)
{
while (left <= right)
{
int mid = (left + right) >> 1;
if (arr[mid]>target)
right = mid - 1;
else
left = mid + 1;
}
return right; //当left=right的时候,此时比target小的值已确定,所以arr[mid]比target小,left+1,跳出循环,此时right代表的还是mid,即为所求
}
int main()
{
int n, m;
int a[MAX], q[MAX];
while (scanf("%d %d", &n, &m) != EOF)
{
memset(a, 0, sizeof(a));
memset(q, 0, sizeof(q));
for (int i = 0; i "%d", &a[i]);
sort(a, a + n);
for (int j = 0; j "%d", &q[j]);
for (int k = 0; k )
{
int c = q[k];
if (c >= a[n - 1])
printf("%d", a[n - 1]);
else if (c <= a[0])
printf("%d", a[0]);
else
printf("%d", a[erfen(a, 0, n, c)]); //直接二分查找,查找小于target的最大数的坐标
if (k != m - 1) printf(" ");
}
printf("\n");
}
return 0;
}