题解 | #查找#

查找

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;
}
全部评论

相关推荐

lingo12:1.最好加个业务项目,大部分面试官工作以后会更偏重业务 2.实习部分描述一般般,可能hr看到会觉得你产出不够不给你过简历 3.蓝桥杯这些大部分人都有的,不如不写,反而减分项。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务