-
Notifications
You must be signed in to change notification settings - Fork 0
/
cf_round_828_div3_B.java
59 lines (54 loc) · 1.44 KB
/
cf_round_828_div3_B.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.util.*;
import java.util.Scanner;
public class cf_round_828_div3_B {
static class Pair{
long x, y;
Pair(long x, long y){
this.x = x;
this.y = y;
}
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t -- > 0){
int n = sc.nextInt();
int k = sc.nextInt();
long a[] = new long[n];
for(int i = 0;i<n;i++){
a[i] = sc.nextInt();
}
long sum = 0;
for(long p : a){
sum += p;
}
long counte = 0, counto = 0;
for(long p : a){
if(p % 2 == 0){
counte ++;
}
else{
counto ++;
}
}
List<Pair> list = new ArrayList<>();
for(int i = 0;i<k;i++){
int x = sc.nextInt();
int xi = sc.nextInt();
list.add(new Pair(x, xi));
}
for(Pair p : list){
if(p.x == 0){
sum += counte*p.y;
System.out.println(sum);
}
else{
if(p.x == 1){
sum += counto*p.y;
}
System.out.println(sum);
}
}
}
}
}