-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFastFood.java
More file actions
68 lines (48 loc) · 1.96 KB
/
FastFood.java
File metadata and controls
68 lines (48 loc) · 1.96 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;
public class FastFood {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int iterations = sc.nextInt();
for(int i =0; i < iterations;i++)
{
int numPrizes = sc.nextInt();
int numTickets = sc.nextInt();
int totalCash = 0;
int tickets [] = new int [numTickets];
int values [] = new int [numPrizes];
ArrayList prizeTickets [] = new ArrayList [30];
for(int x = 0; x < 30; x++)
{
prizeTickets[x] = new ArrayList<Integer>();
}
for(int j = 0; j < numPrizes; j++)
{
int typeTickets = sc.nextInt();
for(int l = 0; l < typeTickets; l++)
{
prizeTickets[j].add(sc.nextInt());
}
values[j] = sc.nextInt();
}
for(int k = 0; k < numTickets; k++)
{
tickets[k] = sc.nextInt();
}
for(int m = 0; m < numPrizes; m++)
{
int smallest = tickets[(Integer)prizeTickets[m].get(0)-1];
for(int n = 0; n < prizeTickets[m].size();n++)
{
if(tickets[(Integer)prizeTickets[m].get(n)-1] < smallest)
{
smallest = tickets[(Integer)prizeTickets[m].get(n)-1];
}
}
totalCash += values[m] * smallest;
}
System.out.println(totalCash);
}
}
}