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<inta;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a.push_back(x);
    }
    cin>>m;
    vector<intb;
    for(int i=0;i<m;i++){
        int x;
        cin>>x;
        b.push_back(x);
    }
    vector<intc;
    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(fbreak;
    }
    return 0;
}

Comments

Popular posts from this blog

Solution of 'The Two Dishes' (Codechef)

Solution of 'Tom Riddle's Diary' (Codeforces)

Solution to the problem 'Red Light, Green Light' from Codechef