Processing math: 100%
Binary search 3 - MarisaOJ: Marisa Online Judge

Binary search 3

Time limit: 1000 ms
Memory limit: 256 MB
You are given: - An integer non-decreasing array A of n integers. - q queries, each is an integer x, find the biggest i that Ai≤x. ### Input - The first line contains 2 integer n,q. - The second line contains n space-separated integers Ai. - The next q lines, each contains an single integer x, a query. ### Output - Print q lines, ith line is the answer to query i. Print -1 no position can be found. ### Constraints - 1≤n,q≤105. - 1≤Ai≤109. ### Example Input: 5312339153 Output: 144