Electronics Shop

 Question :-

https://www.hackerrank.com/challenges/electronics-shop/problem

Solution in C language :-

#include<stdio.h>
int main()
{
    int b,n,m;
    scanf("%d%d%d",&b,&n,&m);
    int i,j,x[n],y[m];
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    for(i=0;i<m;i++){
        scanf("%d",&y[i]);
    }

    int t=0,temp;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            temp=x[i]+y[j];
            if(temp<=b && t<temp){
                t=temp;
            }
        }
    }
    
    if(t==0)
    printf("-1");
    else {
    printf("%d",t);
    }
    return 0;
}

Comments

Popular posts from this blog

Sherlock and Squares

Cut The Sticks

Home