aboutsummaryrefslogtreecommitdiff
path: root/codechef/FinalSum/main.cpp
blob: 4fc98d867745b3afdde7d7e332f6a7b1dad1cc73 (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
#include<bits/stdc++.h>

using namespace std;

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt;
	cin >> tt;
	while(tt--){
    int n, q;
    cin >> n >> q;
    vector<int> v(n);
    for(auto &x : v) {
      cin >> x;
    }
    int k = 0;
    while(q--) {
      int x, y;
      cin >> x >> y;
      k += (y - x + 1) % 2;
    }
    cout << accumulate(v.begin(), v.end(), 0) + k << '\n';
	}
}