-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelecshop.c
More file actions
40 lines (35 loc) · 1010 Bytes
/
Copy pathelecshop.c
File metadata and controls
40 lines (35 loc) · 1010 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
37
38
39
40
#include <bits/stdc++.h>
using namespace std;
int getMoneySpent(vector < int > keyboards, vector < int > drives, int s,int n,int m){
int i,j ,ans=0;
for(i=0;i<n;i++){
for(j=0;j<m;j++){
if(s>=keyboards[i]+drives[j]){
if(ans<keyboards[i]+drives[j]){
ans=keyboards[i]+drives[j];}
}
}
}
if(ans==0){return -1;}
else{
return ans;
}
}
int main() {
int s;
int n;
int m;
cin >> s >> n >> m;
vector<int> keyboards(n);
for(int keyboards_i = 0; keyboards_i < n; keyboards_i++){
cin >> keyboards[keyboards_i];
}
vector<int> drives(m);
for(int drives_i = 0; drives_i < m; drives_i++){
cin >> drives[drives_i];
}
// The maximum amount of money she can spend on a keyboard and USB drive, or -1 if she can't purchase both items
int moneySpent = getMoneySpent(keyboards, drives, s,n,m);
cout << moneySpent << endl;
return 0;
}