-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHelp_Ramu.java
40 lines (36 loc) · 1.25 KB
/
Help_Ramu.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
29
30
31
32
33
34
35
36
37
38
39
40
import java.util.Scanner;
public class Help_Ramu {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int test = sc.nextInt();
while (test-- > 0) {
int c1 = sc.nextInt();
int c2 = sc.nextInt();
int c3 = sc.nextInt();
int c4 = sc.nextInt();
int n = sc.nextInt();// Rickshaw
int m = sc.nextInt();// Cab
int Rickshaws[] = new int[n];
int Cabs[] = new int[m];
for (int i = 0; i < Rickshaws.length; i++) {
Rickshaws[i] = sc.nextInt();
}
for (int i = 0; i < Cabs.length; i++) {
Cabs[i] = sc.nextInt();
}
int totalr = 0;
int totalc = 0;
for (int i = 0; i < Rickshaws.length; i++) {
totalr += Math.min(Rickshaws[i] * c1, c2);
}
for (int i = 0; i < Cabs.length; i++) {
totalc += Math.min(Cabs[i] * c1, c2);
}
totalr = Math.min(totalr, c3);
totalc = Math.min(totalc, c3);
int ans = Math.min(c4, totalc + totalr);
System.out.println(ans);
}
}
}