Codeforces 1206A. Choose Two Numbers Solultion

Solve in C++:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,j,m,ar[201]={0},br[201]={0},vis[1000]={0},s=0,f=0;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>ar[i];
        vis[ar[i]]=1;
    }
    cin>>m;
    for(j=0; j<m; j++)
    {
        cin>>br[j];
        vis[br[j]]=1;
    }
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            s=ar[i]+br[j];
            if(vis[s]!=1)
            {
                cout<<ar[i]<<" "<<br[j]<<endl;
                f=1;
                break;
            }
            
        }
         if(f==1)
        break;
    }

}

No comments

Most View Post

Recent post

RESTful APIs with CRUD Operations in Laravel 12| (2025)

  RESTful APIs serve as the foundation of modern web development. They follow a set of rules called Representational State Transfer (REST) t...

Powered by Blogger.