五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

CF 1744B - Even-Odd Increments

2023-08-18 16:14 作者:您是打尖兒還是住店呢  | 我要投稿

You are given n of integers a1,a2,…,an. Process q queries of two types:

query of the form "0 xj": add the value xj to all even elements of the array a,query of the form "1 xj": add the value xj to all odd elements of the array a.

Note that when processing the query, we look specifically at the odd/even value of ai, not its index.

After processing each query, print the sum of the elements of the array a.

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++).


Input

The first line of the input contains an integer t (1≤t≤104) — the number of test cases.

The descriptions of the test cases follow.

The first line of each test case contains two integers n and q (1≤n, q≤105) — the length of array a and the number of queries.

The second line of each test case contains exactly n integers: a1,a2,…,an (1≤ai≤109) — elements of the array a.

The following q lines contain queries as two integers typej and xj (0≤typej≤1, 1≤xj≤104).

It is guaranteed that the sum of values n over all test cases in a test does not exceed 105. Similarly, the sum of values q over all test cases does not exceed 105.

Output

For each test case, print q numbers: the sum of the elements of the array a after processing a query.

----------------------------------------

給定 n 個(gè)整數(shù) a1,a2,…,an。 處理兩種類型的 q 查詢:

“0 xj”形式的查詢:將值 xj 添加到數(shù)組 a 的所有偶數(shù)元素,“1 xj”形式的查詢:將值 xj 添加到數(shù)組 a 的所有奇數(shù)元素。

請(qǐng)注意,在處理查詢時(shí),我們專門查看 ai 的奇/偶值,而不是其索引。

處理完每個(gè)查詢后,打印數(shù)組 a 的元素之和。

請(qǐng)注意,某些測(cè)試用例的答案不適合 32 位整數(shù)類型,因此您應(yīng)該在編程語言中至少使用 64 位整數(shù)類型(例如 C++ 的 long long)。


輸入

輸入的第一行包含一個(gè)整數(shù) t (1≤t≤104) — 測(cè)試用例的數(shù)量。

測(cè)試用例的描述如下。

每個(gè)測(cè)試用例的第一行包含兩個(gè)整數(shù)n和q(1≤n,q≤105)——數(shù)組a的長(zhǎng)度和查詢的數(shù)量。

每個(gè)測(cè)試用例的第二行恰好包含 n 個(gè)整數(shù):a1,a2,…,an (1≤ai≤109) — 數(shù)組 a 的元素。

以下 q 行包含兩個(gè)整數(shù) typej 和 xj (0≤typej≤1, 1≤xj≤104) 的查詢。

保證一次測(cè)試中所有測(cè)試用例的 n 值之和不超過 105。同樣,所有測(cè)試用例的 q 值之和不超過 105。

輸出

對(duì)于每個(gè)測(cè)試用例,打印 q 個(gè)數(shù)字:處理查詢后數(shù)組 a 的元素之和。

-------------------------------------

代碼明明沒問題的,結(jié)果報(bào)錯(cuò)了好幾次。。。


CF 1744B - Even-Odd Increments的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
文山县| 武胜县| 左权县| 平塘县| 元朗区| 津市市| 祥云县| 嘉义市| 略阳县| 金昌市| 昂仁县| 施甸县| 美姑县| 英德市| 登封市| 遂昌县| 晴隆县| 宁远县| 安远县| 大丰市| 长治县| 中卫市| 普宁市| 铜鼓县| 鄂托克前旗| 铁力市| 宽甸| 桂林市| 正阳县| 铜山县| 饶阳县| 旬邑县| 资溪县| 板桥市| 岢岚县| 从江县| 彰武县| 吴川市| 香港| 崇义县| 乌鲁木齐县|