Electronics Shop | Hackerrank Solution in C++

Electronics Shop | Hackerrank Solution


It is an hackerrank problem you can find it by clicking here.
  Below given solution is prepared by one of the coder of our.
                           
                                               Soultion in C++

#include<iostream>

using namespace std;

int main(){

    int s,n,m,a,cost = -1;
    int keyboard[1001],usb[1001];

    cin >> s >> n >> m;
    for(int i = 0; i < n; i++)cin >> keyboard[i];
    for(int i = 0; i < m; i++)cin >> usb[i];

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(keyboard[i]+usb[j] <= s)
                cost = max(cost,keyboard[i]+usb[j]);
        }
    }
    cout<<cost<<endl;
    return 0;
}



Hope your doubt regarding this problem is clear.

This solution is POWERED By : Coding Winds


Comments

Popular posts from this blog

Apple and Orange | Hackerrank Solution in C++

Maximum Draws | Hackerrank Solution in C++

Minimum Distances | Hackerrank Solutions in C++