aboutsummaryrefslogtreecommitdiff
path: root/codechef/FinalSum/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'codechef/FinalSum/main.cpp')
-rw-r--r--codechef/FinalSum/main.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/codechef/FinalSum/main.cpp b/codechef/FinalSum/main.cpp
new file mode 100644
index 0000000..4fc98d8
--- /dev/null
+++ b/codechef/FinalSum/main.cpp
@@ -0,0 +1,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';
+ }
+}