-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElectronics_Shop.cpp
More file actions
36 lines (34 loc) · 883 Bytes
/
Electronics_Shop.cpp
File metadata and controls
36 lines (34 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Title : Electronics_Shop.cpp
* Author : Tridib Samanta
* Created : 19-12-2019
* Link : https://www.hackerrank.com/challenges/electronics-shop/problem
**/
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int b,n,m;
scanf("%d%d%d",&b,&n,&m);
int keyboard[n],usb_drive[m];
for(int i=0;i<n;i++)
scanf("%d",&keyboard[i]);
for(int j=0;j<m;j++)
scanf("%d",&usb_drive[j]);
int max_cost=-1;
for(int k=0;k<n;k++) {
for(int l=0;l<m;l++) {
if((keyboard[k]+usb_drive[l])<=b && (keyboard[k]+usb_drive[l])>max_cost)
max_cost=keyboard[k]+usb_drive[l];
}
}
printf("%d\n",max_cost);
return 0;
}