题解 | #查找#
查找
http://www.nowcoder.com/practice/8e0c0e8c78944847be9bca54b59d713f
#include<bits/stdc++.h>
using namespace std;
int main(){
set<int>s;
//write your code here......
int n, m, x;
cin>>n>>m;
for (int i = 0; i < n; i++) {
cin>>x;
s.insert(x);
}
while (m--) {
cin>>x;
auto it = s.upper_bound(x);
if (it == s.end()) cout<<-1<<endl;
else cout<<*it<<endl;
}
return 0;
}