Eddard and his secret partner are betting on how many problems each contestant will solve in Game Of Coders this year. Eddard knows his secret partner would win the bet if they played fairly, so he decided to get some outside help – your help.
$$$m$$$ contestants have signed up for the contest, and will be given $$$n$$$ problems and $$$t$$$ minutes to solve them. Each contestant $$$i$$$ has a rating $$$r_i$$$, and each problem $$$i$$$ has a difficulty rating $$$d_i$$$, time to solve $$$ts_i$$$, and time to fail $$$tf_i$$$.
Eddard believes this is how each contestant $$$c$$$ performs:
This process repeats until the time runs out or the contestant has picked every problem once.
For each contestant, print the expected number of solved problems after the contest ends.
Note that if the time runs out at the same minute a contestant finishes solving a problem, the problem is counted as solved.
The first line of input consists of 3 integers $$$n, m, t (1 \le n \le 12, 1 \le m \le 10^5, 1 \le t \le 300)$$$
The next three lines of input describe the problems and consist of $$$n$$$ integers each:
The last line consists of $$$m$$$ integers $$$r_1, r_2,...,r_m(1 \le r_i \le 9999)$$$, The rating of each contestant.
print $$$m$$$ integers $$$e_1, e_2,...,e_m$$$, where $$$e_i$$$ is the expected number of problems contestant $$$i$$$ will solve modulo $$$10^9 + 7$$$.
Formally, the expected number can be expressed as an irreducible fraction $$$\frac{x}{y}$$$. You have to print the value of $$$x \cdot y^{-1} \mbox{ mod } 10^9 + 7$$$, where $$$y^{-1}$$$ is an integer such that $$$y \cdot y^{-1} \equiv 1 \mbox{ (mod } 10^9 + 7)$$$.
1 2 5010005050500 1500
0 1
6 8 150800 1200 1500 1800 2200 26002 5 15 25 40 6010 12 20 40 30 100900 1300 3000 1260 2500 1750 200 1979
433333337 100000002 6 100000002 716666675 766666674 0 216666671
In the first test Case:
the first contestant has rating $$$500$$$, they pick the only problem with difficulty $$$1000$$$ and spend the $$$50$$$ minutes of the contest trying to solve it but fail, thus solving 0 problems.
The second contestant has rating $$$1500$$$, so they're able to solve it in $$$50$$$ minutes, thus solving 1 problem.
In the second test case, the answer as irreducible fractions is:
$$$ \frac{19}{30}, \frac{13}{10}, \frac{6}{1}, \frac{13}{10}, \frac{199}{60}, \frac{59}{30}, \frac{0}{1}, \frac{169}{60}$$$
A book's table of contents is a page which lists every chapter and the number of its first page and chapters are sorted by their first page. For example, the following is a table of contents:
While reading, Eddard dropped his book and its table of contents got shuffled, the rest of the book is fine, and every chapter is still mapped to its first page correctly in the table of contents, but the order of the chapters in the list got messed up. For example, the above table of contents might now look like this:
Now, Eddard can't know which chapter he is supposed to read, he only remembers the title of the last chapter he finished. So, he went to his wise secret partner to ask for help, but his partner said he should act responsibly and take care of it himself.
Since Eddard obviously can't take care of it himself, he needs your help. Also, be ready to be asked many times as he will ask you repeatedly for help in the same book.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ $$$(1 \le t \le 10^4)$$$. The description of the test cases follows.
The first line of each test case contains two integers $$$n, q$$$ $$$(1 \le n, q \le 10^5)$$$ – The number of chapters in the book and the number of queries, respectively.
Each of the next $$$n$$$ lines contains a string $$$s$$$ and an integer $$$p$$$ $$$(1 \le |s| \le 15, 1 \le p \le 10^9)$$$ – the title of the chapter and its starting page. It is guaranteed that each chapter is at least one page (No two chapters in the table of contents will have the same starting page) and that no two chapters have the same name.
Each of the next $$$q$$$ lines contains a string $$$c$$$ $$$(1 \le |c| \le 15)$$$ – the title of the last chapter Eddard just finished. It is guaranteed that the title of the chapter exists in the table of contents.
It is guaranteed that sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$. All strings consist of lowercase and uppercase letters and numbers.
For each query, print the title of the next chapter Eddard is supposed to read in a single line. If the chapter was the last one in the book, print "No More Chapters".
23 3Chapter2 43Chapter3 60Chapter1 1Chapter1Chapter2Chapter33 1SecondChapter 4FirstChapter 1ThirdChapter 24FirstChapter
Chapter2 Chapter3 No More Chapters SecondChapter
The first test case is explained in the statement
In the second test case, the table of contents should be ordered as follows:
And the next chapter to FirstChapter should be SecondChapter
Eddard and his secret partner are visiting The Rectangular City for $$$k$$$ days, and they have a plan $$$P$$$ for their trip.
The Rectangular City is built as a $$$n × m$$$ grid of blocks. Each block $$$(x, y)$$$ is of type $$$t_{x,y}$$$ and has a teleportation device and a metro station.
On the $$$i$$$-th day, the couple will visit any block of their choice of type $$$P_i$$$.
For example, for $$$P$$$ = "goc", they will spend $$$3$$$ days. On the first day, they'll visit any block of type g, the next day, a block of type o, and on the last day, a block of type c.
On the first day, they arrive at any block they want. Afterwards, going from one block to another is done in the following steps:
The teleportation device is free. However, the metro isn't. If they use the metro to travel from block $$$(x_1, y_1)$$$ to block $$$(x_2, y_2)$$$, they pay $$$|x_1 - x_2| + |y_1 - y_2|$$$ rectangles (The Rectangular City's currency). Check the examples and explanations below.
Since Eddard and his secret partner aren't very rich, they want to spend the least amount of rectangles. Find the minimum amount of rectangles they need to pay in their trip.
The first line of input consists of a single integer $$$T (1 \le T \le 10^4)$$$ – the number of test cases.
Each test case is given as the following:
The first line consists of 3 integers $$$n, m, k(1 \le n, m \le 10^6, 1 \le k \le 10^6)$$$.
Each of the next $$$n$$$ lines consists of a string $$$t_x$$$ of size $$$m$$$, where $$$t_{x,y}$$$ is the type of block $$$(x, y)$$$.
The next line consists of a string $$$P$$$ of size $$$k$$$ – the plan for the trip. It is guaranteed that each character in $$$P$$$ appears at least once in $$$t$$$.
All strings consist of lowercase letters.
It is guaranteed that both the sum of $$$n*m$$$ and the sum of $$$k$$$ over all test cases do not exceed $$$10^6$$$.
For each test case, print a single integer, the minimum amount of rectangles they need to pay in their trip.
33 4 5anacnyncanacycnan5 5 4abbbbcccccdddddeeeeeffffgadga1 1 2xxx
5 12 0
A possible scenario in the first test case is the following:
For the second test case:
Eddard has wanted to learn about FFT for a very long time, but he's a little lazy and is intimidated by its difficulty and complexity. However, he found a simple meme explaining what the Fourier Transform is.
Fourier Transform explanation. (Check the notes if the image is not loading. He decided to find a fast algorithm that can find the base for any number that makes it the "Fouriest", basically inventing the Fast Fourier Transform. Can you help him?
The first line of input consists of a single integer $$$T (1 \le T \le 10)$$$, the number of test cases.
Each test case is given in one line containing a single integer $$$n(5 \le n \le 10^{12})$$$
For each test case, print a single integer $$$b(2 \le b \le 2 \cdot 10^{12})$$$, the base where $$$n$$$ becomes "Fouriest". If no $$$b$$$ exists where the representation of $$$n$$$ has at least 1 four, print $$$-1$$$. If multiple solutions exist, print the largest.
410242044444
6 5 16 10
Test Cases Explanation:
$$$(10)_{10}$$$ = $$$(14)_6$$$
$$$(24)_{10}$$$ = $$$(44)_5$$$
$$$(20)_{10}$$$ = $$$(40)_{5}$$$ = $$$(14)_{16}$$$ Here, $$$20$$$ produces $$$1$$$ four in both bases $$$5$$$ and $$$16$$$, but $$$16$$$ is greater.
$$$44444$$$ is fouriest in base $$$10$$$
Image description:
It's called a Fourier Transform when you take a number and convert it to the base system where it will have more fours, thus making it "Fourier". If you pick the base with the most fours, the number is said to be "Fouriest".
Since watching the game theory session, the secret partner has been beating Eddard in Nim Game every time. So, Eddard got bored and decided they should spice it up a little bit and make a new game with his favorite topic, trees! He decided to call the new game Tim Game, short for Tree Nim Game. He really doesn't know how to come up with creative names.
Eddard and his secret partner are playing a game where they are given a tree with $$$n$$$ nodes rooted at node $$$1$$$. The secret partner goes first, then they alternate turns.
Each turn, a player picks a node $$$u$$$ other than the root, and removes it and all its descendants.
The last player to make a move wins. Equivalently, the player who can't make a move on their turn loses.
Can you find out who will win if both play optimally?
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ $$$(1 \le t \le 10^4)$$$. The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ $$$(1 \le n \le 4 \cdot 10^5)$$$ – The size of the tree.
Each of the next $$$n-1$$$ lines describes an edge $$$(u, v)$$$ $$$(1 \le u, v \le n)$$$.
It is guaranteed that the given edges in each test case form a tree, and the sum of $$$n$$$ over all test cases does not exceed $$$4 \cdot 10^5$$$.
For each test case, print "The Secret Partner" if the secret partner wins. Otherwise, print "Eddard".
361 22 32 41 55 6101 22 33 44 53 61 77 87 99 1021 2
The Secret Partner The Secret Partner The Secret Partner
In the first test case, one possible scenario is the following:
In the second test case, one possible scenario is the following:
No need to explain the third test case, The Secret Partner always wins anyway.
Eddard likes strings. His partner likes Fibonacci numbers. Thus, $$$\mbox{The Fibonacci Strings!}$$$
The Fibonacci string sequence $$$F$$$ can be defined given $$$F_1,$$$ $$$F_2$$$ recursively as follows:
$$$$$$F_i = F_{i-1} + F_{i-2} \mbox{ for } i \gt 2$$$$$$
For example, for $$$F_1 =$$$"a", $$$F_2 =$$$ "b"; $$$F =$$$ {"a", "b", "ba", "bab", "babba", "babbabab", ..}
Given $$$F_1$$$, $$$F_2$$$, and two integers $$$x$$$, $$$k$$$; find the $$$k$$$-th character of $$$F_x$$$.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ $$$(1 \le t \le 10^4)$$$. The description of the test cases follows.
The first line of each test case contains 2 integers $$$n, m$$$ $$$(1 \le n, m \le 10^5)$$$
The second and third lines of each test case contain two strings of lowercase letters, $$$F_1$$$ of size $$$n$$$ and $$$F_2$$$ of size $$$m$$$.
The fourth line of each test case contains 2 integers $$$x, k$$$ $$$(1 \le x \le 1000, 1 \le k \le \mbox{min}(10^{18}, |F_x|))$$$
It is guaranteed that the sum of $$$n + m$$$ over all test cases does not exceed $$$10^5$$$
For each test case, output a single character, the $$$k$$$-th character in $$$F_x$$$.
51 1ab6 72 3abxyz1 24 4nnnnnnnn1000 10000000000000000002 2abcd10 107 6partnersecret3 11
a b n b n
In the first test case, $$$F_6 =$$$ "babbabab", its $$$7$$$th character is "a".
In the second test case, $$$F_1 =$$$ "ab", its $$$2$$$nd character is "b".
In the third test case, all strings consist only of the character "n"
Eddard and his secret partner believe arrays should be symmetric, and any asymmetric array is worthless. So, they defined a function $$$V(a)$$$ as the value of array $$$a$$$ as follows:
Given an array $$$a$$$, calculate $$$\sum_{l=1}^{n}\sum_{r=l}^{n}V(a[l..r])$$$, where $$$a[l..r]$$$ is the subarray of $$$a$$$ from index $$$l$$$ to $$$r$$$.
Since the answer can be too large, print it modulo $$$10^9+7$$$.
* A symmetric array is an array that stays the same when reversed. More formally, in a symmetric array $$$a$$$ of $$$n$$$ integers, $$$a_i = a_{n+1-i}$$$ for $$$1 \le i \le n$$$. For example, the arrays $$$[1, 3, 1], [5, 9, 9, 5], [25]$$$ are symmetric, while $$$[1, 2], [4, 6, 4, 4]$$$ are not.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ $$$(1 \le t \le 10^4)$$$. The description of the test cases follows.
The first line of each test case contains the array length $$$n$$$ $$$(1 \le n \le 10^6)$$$.
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2,...,a_n$$$ $$$(1 \le a_i \le 10^9)$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^6$$$.
For each test case, print the answer modulo $$$10^9 + 7$$$.
531 2 148 9 9 8518 5 18 7 2921 25100 100 100 100 100
8 86 118 3 3500
In the first test case, the subarrays of $$$[1, 2, 1]$$$ are $$$\{[1], [2], [1], [1, 2], [2, 1], [1, 2, 1]\}$$$.
Only $$$[1], [2], [1], [1, 2, 1]$$$ are symmetric, so the answer is their sum: $$$(1) + (2) + (1) + (1 + 2 + 1) = 8$$$.
Eddard's secret partner likes matrices, so they went on a trip to The Matrix City, which is famous for its coffee shops that make the best cappuccino and hot chocolate. While walking around the city, however, they lost each other. Can you help them meet again?
The city consists of $$$n*m$$$ blocks, each block $$$(x, y)$$$ with a coffee shop that serves cappuccino, hot chocolate, both, or neither.
Initially, Eddard is at block $$$(1, 1)$$$ while his partner is at $$$(n, m)$$$. Each of them can move in the four directions. Since it's already summer and the weather is absolutely terrible, walking is tiresome and each step costs $$$1$$$ willpower.
There is, however, something that can save some willpower for them...
Eddard likes hot chocolate, and his partner likes cappuccino. If they're currently at a block with a coffee shop that serves their preferred drink, they can drink and move to any adjacent block without spending willpower.
Find the minimum sum of willpower spent by both so that they can meet at any block.
The first line of input consists of one integer $$$T (1 \le T \le 10^4)$$$ – The number of test cases.
The first line of each test case consists of 2 integers $$$n, m(1\le n, m \le 10^6, n \cdot m \le 10^6)$$$
The $$$i$$$-th line of the next $$$n$$$ lines consists of $$$m$$$ integers $$$a_{i, 1}, a_{i, 2},...,a_{i, m}$$$, where $$$a_{i,j}$$$ describes the drinks served at the coffee shop in block $$$(i, j)$$$:
It is guaranteed that the sum of $$$n \cdot m$$$ over all test cases will not exceed $$$10^6$$$
Print the answer for each test case on a single line.
44 62 2 0 0 0 00 2 0 0 0 00 0 0 0 1 00 0 0 0 1 110 20 00 00 00 00 00 00 00 00 00 03 33 3 33 3 33 3 31 10
2 10 0 0
In the first test case:
Eddard can move as follows: $$$(1, 1) \gt ^0 (1, 2) \gt ^0 (2, 2) \gt ^0 (2, 3) \gt ^1 (3, 3)$$$
His partner can move as follows: $$$(4, 6) \gt ^0 (4, 5) \gt ^0 (3, 5) \gt ^0 (3, 4) \gt ^1 (3, 3)$$$
Eddard suspects his partner is a vampire. Can you help him find out the truth?
Everyone knows only vampires drink cappuccino, so Eddard decided to do a little trick. He would leave some cappuccino on a table where his partner is, then come back and check if his partner drank (or added) any.
Eddard put $$$n$$$ cups of cappuccino on the table and measured the amount of cappuccino in every cup, but he only had a small piece of paper, so he couldn't write down how much each cup had. Instead, he could only write down one number. So, he decided to encode the information into one number using a function.
He defined $$$F(a) = \sum_{i=1}^{n} (i*a_i)$$$ where $$$a$$$ is an array of $$$n$$$ integers. He then wrote down the result of $$$F(c)$$$ on the piece of paper, where $$$c_i$$$ is the amount of cappuccino in the $$$i$$$-th cup.
Eddard left the cups at the table and came back after a while and measured the cups again and found that the amount of cappuccino in the $$$i$$$-th cup is now $$$p_i$$$. Can you help Eddard find out if the amount of cappuccino possibly stayed the same?
Assume that neither the number of cups nor their positions changed.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ $$$(1 \le t \le 10^4)$$$. The description of the test cases follows.
The first line of each test case contains two integers $$$n, F(c)$$$ $$$(1 \le n \le 10^6, 0 \le F(c) \le 10^{18})$$$.
The second line of each test case contains $$$n$$$ integers $$$p_1, p_2, ..., p_n$$$ $$$(0 \le p_i \le 10^9)$$$.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^6$$$.
For each test case, if the amount of cappuccino in the cups has certainly changed, print "NO". Otherwise, print "YES".
You can output the answer in any case (for example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as a positive answer).
55 302 4 2 1 24 10010 10 10 101 543 201 4 11 00
YES YES NO NO YES
Remember to use fast I/O.
In the first test case, $$$F(p) = F(c) = 30$$$. Thus, it is possible that the amount of cappuccino has not changed.
In the third test case, however, $$$F(p) = 4$$$, which differs from $$$F(c)$$$. So, it is certain that the amount of cappuccino changed.
Note that in the first test case, it is possible that the amount of cappuccino has changed. For example, $$$c$$$ could be equal to $$$\{2, 2, 2, 2, 2\}$$$, which would still lead to $$$F(p) = F(c)$$$. The answer is still "YES" as the question is about the possibility of the cups not changing.
Eddard is preparing the Game of Coders problemset, but he can't stop adding hard problems to the contest. His secret partner keeps begging him to make it a little easier, but he gets excited whenever he finds an idea for a hard problem, and he can't find any interesting ideas for easy ones. So his partner decided to take matters into their own hands and make this problem.
Given the number of problems in a contest Eddard will prepare, what is the expected number of hard problems?
The input consists of a single integer $$$n$$$ $$$(1 \le n \le 15)$$$ – the number of problems.
Print a single integer, the expected number of hard problems.
12
12
10
10
15
15
3
3
This is not a trick, just print the input back :3
Eddard and his secret partner found a really cute song called "I am the red tomato" and they really loved it, but something piqued their interest..
"I am the red tomato, planted among the vegetables. You eat me until you're full, and your cheeks go red."
The mystery here is.. how much tomato can they eat?
Eddard and his partner have a hypothesis: The maximum total weight of tomatoes they can eat at one sitting is $$$w$$$ grams, regardless of the number of tomatoes. For example, if $$$w = 9$$$, they can eat 3 tomatoes of weights $$$6, 2, 1$$$, as their total weight is $$$9$$$, but they can't eat 2 tomatoes of weights $$$7, 4$$$, as their total weight is $$$11$$$.
The goal is to find the value $$$w$$$. So, they decided to run the following experiment $$$e$$$ times:
They put $$$n$$$ tomatoes of weights $$$a_1, a_2, ..., a_n$$$ on a table. Then, they start eating the tomatoes from left $$$(1)$$$ to right $$$(n)$$$ until they can't eat any more tomatoes. After they're done, they write down the number of tomatoes left $$$m$$$.
For example, if $$$w = 5$$$, $$$a = [3, 4, 2]$$$, they will eat the first tomato of weight $$$3$$$ then stop since they can't eat the second tomato, as the total weight would be $$$7$$$. They will, then, write down $$$m = 2$$$ as the number of remaining tomatoes.
Can you help them find the value $$$w$$$ after running multiple experiments?
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ $$$(1 \le t \le 10^4)$$$. The description of the test cases follows.
The first line of each test case contains a single integer $$$e$$$ $$$(1 \le e \le 10^6)$$$ – The number of experiments they are running. The description of the experiments follows.
The first line of each experiment contains $$$2$$$ integers $$$n, m$$$ $$$(1 \le n \le 10^6, 0 \le m \le n)$$$ – The number of tomatoes at the start and the end of the experiment, respectively.
The second line of each experiment contains $$$n$$$ integers $$$a_1, a_2, ..., a_n$$$ $$$(1 \le a_i \le 10^9)$$$ – The weights of the tomatoes.
It is guaranteed that sum of $$$n$$$ over all test cases does not exceed $$$10^6$$$
For each test case, print a single integer $$$w$$$ $$$(0 \le w \le 10^{18})$$$ – the answer.
If multiple answers exist, print the smallest. if no answer exists, print "False Hypothesis".
431 053 23 4 25 11 2 1 1 121 051 1611 110023 03 5 64 11 4 2 4
5 5 0 False Hypothesis
In the first test case, $$$3$$$ experiments are run:
From these $$$3$$$ experiments, it can be deduced that the smallest possible value for $$$w$$$ is $$$5$$$
In the fourth test case, after running the $$$2$$$ experiments, it can be deduced that no value $$$w$$$ exists that satisfies both experiments. Thus, the hypothesis is false.
Just like us, letters grow too.
Define $$$F_0 = \mbox{"a"}; F_i = F_{i-1} + \mbox{"b"} + F_{i-1}$$$ for all $$$i \ge 1$$$.
For example, $$$F_1 = F_0 + \mbox{"b"} + F_0 = \mbox{"aba"}$$$.
You are given a string $$$S$$$, but since it can be very large, it is described as an array $$$a$$$ of $$$n$$$ integers, where $$$S = F_{a_1} + F_{a_2} + ... + F_{a_n}$$$.
For example, for $$$a = \{1, 0, 0\}, S = \mbox{"aba" + "a" + "a" = "abaaa"}$$$.
The letters in $$$S$$$ merge and grow together. This is done as follows:
For example, for $$$S = \mbox{"abaaaaba"}$$$, the growing process goes as follows:
$$$\mbox{ab(aa)aaba} \rightarrow \mbox{ab(b)aaba}$$$
$$$\mbox{a(bb)aaba} \rightarrow \mbox{a(c)aaba}$$$
$$$\mbox{ac(aa)ba} \rightarrow \mbox{ac(b)ba}$$$
$$$\mbox{ac(bb)a} \rightarrow \mbox{ac(c)a}$$$
$$$\mbox{a(cc)a} \rightarrow \mbox{a(d)a}$$$
Can you find the size of $$$S$$$ after the growing process is complete?
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ $$$(1 \le t \le 10^4)$$$. The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ $$$(1 \le n \le 10^5)$$$ – The size of the array.
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, ..., a_n$$$ $$$(0 \le a_i \le 15)$$$ – The elements of the array.
It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$
For each test case, output a single integer, the size of $$$S$$$ after the growing process.
341 0 0 180 0 0 0 0 0 0 030 3 0
3 1 13
The first test case is described in the example in the statement.
In the second test case, $$$S = \mbox{"aaaaaaaa"}$$$. It grows into $$$\mbox{"d"}$$$.
The secret partner got tired of the difficult problems Eddard kept adding to the contest, and decided to take matters into their own hands once again and add an easy classical problem, the maximum subarray sum: "Given an array $$$a$$$ of $$$n$$$ integers, find the maximum sum of any subarray."
But, of course, Eddard decided to sabotage the problem and make it a little harder. After all, why shouldn't he? Now, the problem is the maximum subarray alternating sum.
The alternating sum $$$S$$$ of an array $$$b$$$ is given as follows:
$$$S(b) = b_1 - b_2 + b_3 - ... + (-1)^{n + 1} \cdot b_n$$$.
In other words, $$$S(b) =$$$ sum of elements with odd indices $$$-$$$ sum of elements with even indices.
For example, for $$$a = [3, 7, 1, 5]$$$:
$$$S(a_{2..4}) = a_2 - a_3 + a_4 = 7 - 1 + 5 = 11$$$, which is also the maximum subarray alternating sum.
$$$S(a_{1..2}) = a_1 - a_2 = 3 - 7 = -4$$$.
Can you find the maximum subarray alternating sum of the array?
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ $$$(1 \le t \le 10^4)$$$. The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ $$$(1 \le n \le 10^6)$$$ – The size of the array.
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, ..., a_n$$$ $$$(0 \le a_i \le 10^9)$$$ – The elements of the array.
For each test case, print a single integer, the maximum subarray alternating sum of the array $$$a$$$.
343 7 1 551 0 1 0 131 4 24
11 3 24