Solution of 'Choose Two Numbers' (Codeforces)
Hola amigos! Here's my solution of the question- 'Choose Two Numbers' from Codeforces. If you guys have any suggestions for my code or blog or anything, do comment. TY and Happy Coding!
question link: https://codeforces.com/problemset/problem/1206/A
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m,f=0;
cin>>n;
vector<int> a;
for(int i=0;i<n;i++){
int x;
cin>>x;
a.push_back(x);
}
cin>>m;
vector<int> b;
for(int i=0;i<m;i++){
int x;
cin>>x;
b.push_back(x);
}
vector<int> c;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
int h=a[i]+b[j];
if(find(a.begin(),a.end(),h)==a.end()&&find(b.begin(),b.end(),h)==b.end()){
cout<<a[i]<<' '<<b[j];
f++;
break;
}
}
if(f) break;
}
return 0;
}
Comments
Post a Comment