第一题采果子100%通过 /*input 3 2 3 6 9 3 9 */ #include <bits/stdc++.h> using namespace std; typedef long long ll; inline ll read() { char c = getchar(); ll x = 0, f = 1; while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();} while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x * f; } const int inf=0x3f3f3f3f; const int maxn=1e5+50; int w[maxn]; int vis[maxn]; int main(){ int n,m; cin>>n>>m; for(int i=1;i<=n;i++){ cin>>w[i]; vis[w[i]]++; } while(m--){ int q; cin>>q; bool f=0; for(int i=1;i<=n;i++){ if(vis[w[i]+q]){ f=1; cout<<w[i]<<' '<<w[i]+q<<endl; break; } } if(!f) cout<<-1<<' '<<-1<<endl; } return 0; }
点赞 评论

相关推荐

那一天的Java_Java起来:他本来公司就是做这个的,不就是正常的游戏客户端和服务器开发,软硬件联动,有啥恶心不恶心的,提前告诉你就是怕你接受不了,接受不了就没必要再往后走流程浪费时间,虽然这公司是一坨。
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务