public class Monica {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int b= sc.nextInt();
int n= sc.nextInt();
int m= sc.nextInt();
int [] keyboard = new int[n];
int[] drives = new int[m];
for(int i = 0;i<n;i++){
keyboard[i]=sc.nextInt();
}
for(int i = 0;i<m;i++){
drives[i]=sc.nextInt();
}
int high =-1;
for(int i =0;i<n;i++){
for(int j=0;jhigh && keyboard[i]+drives[j]<b){
high = keyboard[i]+drives[j];
}
}
}
System.out.println(high);
}
}
b,m,n=map(int,input().split(” “))
l1=list(map(int,input().split(” “)))
l2=list(map(int,input().split(” “)))
l=[]
for x in l1:
for y in l2:
if x+y0:
print(max(l))
else:
print(“-1”)
def getmoneyspent(mny,key,drives):
key = sorted(key,reverse=True)
drives = sorted(drives,reverse=True)
maxi = 0
for i in key :
for j in drives:
sm = i + j
if sm maxi:
maxi = sm
return(maxi)
#include
void getmoneyspent(int x,int y[10],int b[10],int h,int c);
main()
{
int m,n,z,i,d;
int k[100],u[100];
printf(“enter the given amount”);
scanf(“%d”,&m);
printf(“enter the number of keyboard available in the store”);
scanf(“%d”,&n);
printf(“enter the keyboard prices”);
for(i=0;i<n;i++)
{
scanf("%d",&k[i]);
}
printf("enter the number of usb available in the store");
scanf("%d",&z);
printf("enter the usb prices");
for(i=0;i<z;i++)
{
scanf("%d",&u[i]);
}
getmoneyspent(m,k,u,n,z);
}
void getmoneyspent(int x,int y[10],int b[10],int h,int c)
{
int i,j;
int max=-1;
for(i=0;i<h;i++)
{
for(j=0;j<c;j++)
{
if((y[i]+b[j]max)
{
max=y[i]+b[j];
}
}
}
printf(“%d”,max);
}
import java.util.*;
public class Monica {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int b= sc.nextInt();
int n= sc.nextInt();
int m= sc.nextInt();
int [] keyboard = new int[n];
int[] drives = new int[m];
for(int i = 0;i<n;i++){
keyboard[i]=sc.nextInt();
}
for(int i = 0;i<m;i++){
drives[i]=sc.nextInt();
}
int high =-1;
for(int i =0;i<n;i++){
for(int j=0;jhigh && keyboard[i]+drives[j]<b){
high = keyboard[i]+drives[j];
}
}
}
System.out.println(high);
}
}
#Python
b,m,n=map(int,input().split(” “))
l1=list(map(int,input().split(” “)))
l2=list(map(int,input().split(” “)))
l=[]
for x in l1:
for y in l2:
if x+y0:
print(max(l))
else:
print(“-1”)
##Python Code
def getmoneyspent(mny,key,drives):
key = sorted(key,reverse=True)
drives = sorted(drives,reverse=True)
prices = []
for i in key :
for j in drives:
sm = i + j
if sm <= mny:
prices.append(sm)
rsl = sorted(prices,reverse=True)
return(rsl[0])
fsin = input()
fsin = fsin.split(' ')
fsin = list(map(int,fsin))
mny = fsin[0]
key = input()
key = key.split(' ')
key = list(map(int,key))
drives = input()
drives = drives.split(' ')
drives = list(map(int,drives))
print(getmoneyspent(mny,key,drives))
#please reply if you better python code for this
Little change here :
def getmoneyspent(mny,key,drives):
key = sorted(key,reverse=True)
drives = sorted(drives,reverse=True)
maxi = 0
for i in key :
for j in drives:
sm = i + j
if sm maxi:
maxi = sm
return(maxi)
fsin = input()
fsin = fsin.split(‘ ‘)
fsin = list(map(int,fsin))
mny = fsin[0]
key = input()
key = key.split(‘ ‘)
key = list(map(int,key))
drives = input()
drives = drives.split(‘ ‘)
drives = list(map(int,drives))
print(getmoneyspent(mny,key,drives))
#include
#include
#include
int getmoneyspend(int key[],int usb[],int n, int m)
{
int i=0,j=0,k=0,l=0,temp=0,flag=0;
int a[100];
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
a[k]=key[i]+usb[j];
k++;
}
}
for(i=0;i=10)
{
a[i]=0;
flag+=1;
}
}
if(flag==k)
{
return -1;
}
else
{
for(i=0;i<k;i++)
{
for(j=i+1;j<k;j++)
{
if(a[i]<a[j])
temp=a[j];
a[j]=a[i];
a[i]=temp;
}
}
return a[0];
}
}
int main()
{
int b=0,n=0,m=0,i=0,res=0;
printf("Enter b,n,m\n");
scanf("%d%d%d",&b,&n,&m);
int key[n],usb[m];
printf("Enter Keyboard Costs\n");
for(i=0;i<n;i++)
{
scanf("%d", &key[i]);
}
printf("Enter USB Costs\n");
for(i=0;i<m;i++)
{
scanf("%d", &usb[i]);
}
res=getmoneyspend(key,usb,n,m);
printf("\n%d",res);
}
#include
void getmoneyspent(int x,int y[10],int b[10],int h,int c);
main()
{
int m,n,z,i,d;
int k[100],u[100];
printf(“enter the given amount”);
scanf(“%d”,&m);
printf(“enter the number of keyboard available in the store”);
scanf(“%d”,&n);
printf(“enter the keyboard prices”);
for(i=0;i<n;i++)
{
scanf("%d",&k[i]);
}
printf("enter the number of usb available in the store");
scanf("%d",&z);
printf("enter the usb prices");
for(i=0;i<z;i++)
{
scanf("%d",&u[i]);
}
getmoneyspent(m,k,u,n,z);
}
void getmoneyspent(int x,int y[10],int b[10],int h,int c)
{
int i,j;
int max=-1;
for(i=0;i<h;i++)
{
for(j=0;j<c;j++)
{
if((y[i]+b[j]max)
{
max=y[i]+b[j];
}
}
}
printf(“%d”,max);
}
//code in C
#include
int main()
{
int b,usb[1000],key[1000],no=-1,i,j,n,m,result=0;
scanf(“%d %d %d”,&b,&n,&m);
for(i=0;i<n;i++)
{
scanf("%d",&key[i]);
}
for(j=0;j<m;j++)
{
scanf("%d",&usb[j]);
}
for(int i=0;i<n;i++)
{
for(int j=0;jno && result<=b)
{
no=result;
}
}
}
printf("%d",no);
}