1104 : Tian Ji's Horse Race Again

时间限制Time Limit 2 Sec 内存限制Memory Limit 128 MB 提交次数Submitted 63 Times 通过次数Solved 12 Times 标准评测Standard Judge

题目描述Description

Last time, the king of the country Qi lost to Tian Ji in a horse race as Tian using a little trick. Today, the king invites Tian to play another horse race. The king and Tian both have n horses, and no two horses have the same speed. They will play n rounds in this match. The horses on each side must appear in descending order of speed, and each of the horses must be used in one round. The horse with a faster speed will win in a single round. Since Tian’s horses are not so nice as the king’s, the king allows Tian to exchange some horses with him.

If Tian can exchange at most k horses with the king, what is the maximum number of rounds that Tian can win?

输入格式Input

There will be at most 200 test cases. Each case begins with two integers n, m(1 ≤ m ≤ n ≤ 105), the number of horses on each side and the number of queries. The next line contains n positive integers, denoting the speeds of king’s horses in descending order. Then the following line contains n positive integers, denoting the speeds of Tian’s horses in descending order. The speed of each horse will not exceed 106, and no two horses have the same speed. The queries are defined by the following m lines, and each line contains one integer k(0 ≤ k < n). The size of the whole input file does not exceed 10MB.

输出格式Output

For each query, print the maximum number of rounds that Tian can win, when he can exchange at most k horses with the king.

样例Sample

出题Author

Staginner