#D. 二分查找

    Type: Default 1000ms 256MiB

二分查找

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

输入n个不大于1e9的单调不减的非负整数然后有m次询问,对于每次询问输出该数字在数列中第一次出现时的序号。如果没有找到输出-1。

输入格式

第一行 2 个整数 n 和 m,表示数字个数和询问次数。 1<=n<=1e6,1<=m<=1000;

第二行 n 个整数,表示这些待查询的数字。

第三行 m 个整数,表示询问这些数字的编号,从 1 开始编号。

输出格式

m个整数表示答案

样例

11 3
1 3 3 3 5 7 9 11 13 15 15
1 3 6
1 2 -1 

Limitation

2s, 1024KiB for each test case.

第三届SWPUACM新生赛-热身赛

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
4
Start at
2021-10-23 14:30
End at
2021-10-23 17:30
Duration
3 hour(s)
Host
Partic.
73