aboutsummaryrefslogtreecommitdiff
path: root/contests/Round828/Round#828/B/main.cpp
blob: e2d3d5d41f432c68a6855fc9c815e6d9fba164bf (plain)
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
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt;
	cin >> tt;
	while(tt--) {
    int n, q;
    cin >> n >> q;
    vector<long long> v(n);
    int even = 0, odd = 0;
    long long ans = 0;
    for (int i = 0 ; i < n; i++) {
      cin >> v[i];
      odd += (v[i] & 1);
      ans += v[i]; 
    }
    even = n - odd;
    while (q--) {
      int t, x;
      cin >> t >> x;
      if (t == 0) {
        ans += even * x;
        if (x & 1) {
          odd += even;
          even = 0;
        } 
      } else {
        ans += odd * x;
        if (x & 1) {
          even += odd;
          odd = 0;
        } 
      }
      cout << ans << '\n';
    }
	}
}