-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path1744_B_Even_odd_Increaments.cpp
More file actions
46 lines (43 loc) · 953 Bytes
/
1744_B_Even_odd_Increaments.cpp
File metadata and controls
46 lines (43 loc) · 953 Bytes
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
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int n, q;
cin >> n >> q;
vector<int> a(n);
long long total = 0;
int even = 0, odd = 0;
for(int i=0; i<n; i++){
cin >> a[i];
total += a[i];
if(a[i] % 2 == 0){
even++;
}
else{
odd++;
}
}
for(int i=0; i<q; i++){
int x, y;
cin >> x >> y;
if(x == 0){
total += even * y;
if(y%2 != 0){
odd += even;
even = 0;
}
}
else{
total += odd * y;
if(y%2 != 0){
even += odd;
odd = 0;
}
}
cout << total << endl;
}
}
return 0;
}