- Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathBusinessProblem.java
28 lines (28 loc) · 975 Bytes
/
BusinessProblem.java
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
// problem: https://codeforces.com/problemset/problem/981/B
importjava.util.Scanner;
importjava.util.HashMap;
publicclassBusinessProblem{
publicstaticvoidmain(String[] args){
ScannersObj = newScanner(System.in);
intn = sObj.nextInt();
HashMap<Long,Long> hMap = newHashMap<Long,Long>();
Longtemp;
Longvalue;
for(intz=0; z<n; z++){
temp = sObj.nextLong();
value = sObj.nextLong();
if(hMap.containsKey(temp)) if(hMap.get(temp) > value) continue;
hMap.put(temp, value);
}
intm = sObj.nextInt();
for(intzz=0; zz<m; zz++){
temp = sObj.nextLong();
value = sObj.nextLong();
if(hMap.containsKey(temp)) if(hMap.get(temp) > value) continue;
hMap.put(temp, value);
}
Longtotal = (long) 0;
for(Longele: hMap.values()) total += ele;
System.out.println(total);
}
}