0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-24 01:08:47 +00:00

P2249 【深基13.例1】查找

R39757575
This commit is contained in:
Baoshuo Ren 2020-10-13 20:52:00 +08:00 committed by Baoshuo Ren
parent b7bd763197
commit d263a9d982
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

24
problem/P2249/P2249.cpp Normal file
View File

@ -0,0 +1,24 @@
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, t, m;
vector<int> nums;
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> t;
nums.push_back(t);
}
for (int i = 0; i < m; i++) {
cin >> t;
vector<int>::iterator it = lower_bound(nums.begin(), nums.end(), t);
if (*it == t) {
cout << it - nums.begin() + 1 << ' ';
}
else {
cout << "-1 ";
}
}
return 0;
}