[Solution] Even-Odd Increments Codeforces Solution
You are given of integers . Process queries of two types:
- query of the form "0 ": add the value to all even elements of the array ,
- query of the form "1 ": add the value to all odd elements of the array .
Note that when processing the query, we look specifically at the odd/even value of , not its index.
After processing each query, print the sum of the elements of the array .
Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
The first line of the input contains an integer ) — the number of test cases.
The descriptions of the test cases follow.
The first line of each test case contains two integers and (, ) — the length of array and the number of queries.
The second line of each test case contains exactly integers: () — elements of the array .
The following lines contain queries as two integers and , ).
It is guaranteed that the sum of values over all test cases in a test does not exceed . Similarly, the sum of values over all test cases does not exceed .
For each test case, print numbers: the sum of the elements of the array after processing a query.
In the first test case, the array after the first query.
In the third test case, the array is modified as follows: .
No comments:
Post a Comment