-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodechef2.cpp
More file actions
79 lines (72 loc) · 1.77 KB
/
Copy pathcodechef2.cpp
File metadata and controls
79 lines (72 loc) · 1.77 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
69
70
71
72
73
74
75
76
77
78
79
/*
Little Elephant likes lemonade.
When Little Elephant visits any room, he finds the bottle of the lemonade in that room that contains the greatest number of litres of lemonade and drinks it all.
There are n rooms (numbered from 0 to n-1), each contains Ci bottles. Each bottle has a volume (in litres). The first room visited by Little Elephant was P0-th, the second - P1-th, ..., the m-th - Pm-1-th room. Note that Little Elephant may visit a room more than once.
Find for Little Elephant the total volume of lemonade he has drunk.
Input
First line of the input contains single integer T - the number of test cases. T test cases follow. First line of each test case contains
pair of integers n and m. Second line contains m integers separated by a single space - array P. Next n lines describe bottles in each
room in such format: Ci V0 V1 ... VCi-1, where V is the list of volumes (in liters) of all bottles in i-th room.
Output
In T lines print T integers - the answers for the corresponding test cases.
Constraints
1 <= T <= 10
1 <= n, Ci <= 100
1 <= m <= 10^4
0 <= Pi < n
1 <= Vi <= 10^5
Example
Input:
2
3 3
0 2 1
3 1 2 3
1 7
2 4 7
4 7
0 1 3 0 1 0 0
1 7
3 9 4 5
7 1 2 3 4 5 6 7
1 1
Output:
17
22
*/
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
int no_test;
cin>>no_test;
while(no_test>0)
{
long int n,m;
cin>>n>>m;
int *arr1 =new int[m+1];
int i=0;
while(i<m)
{
cin>>arr1[i++];
}
vector<vector<int>> vec;
i=0;
while(i<n)
{
vector<int> temp;
int num;
cin>>num;
int p=0;
while(p<num)
{
int num1;
cin>>num1;
temp.push_back(num1);
}
sort(temp.begin(),temp.end());
vec.push_back(temp);
}
}
}