C1. Pokémon Army (easy version) SOLUTION Codeforces Round #672 (Div. 2)

Pokémon Army (easy version) SOLUTION

This is the simple variant of the issue. The contrast between the adaptations is that the simple rendition has no trade tasks. You can make hacks just if all renditions of the issue are fathomed. 
Pikachu is an adorable and benevolent pokémon living in the wild pikachu group. 
However, it has become known as of late that notorious group R needed to take all these pokémon! Pokémon coach Andrew chose to help Pikachu to construct a pokémon armed force to stand up to. 
To begin with, Andrew tallied all the pokémon — there were actually n pikachu. The quality of the I-th pokémon is equivalent to ai, and every one of these numbers are particular. 
As a military, Andrew can pick any non-void aftereffect of pokemons. As it were, Andrew picks some exhibit b from k records with the end goal that 1≤b1<b2<⋯<bk≤n, and his military will comprise of pokémons with powers ab1,ab2,… ,abk. 
The quality of the military is equivalent to the substituting whole of components of the aftereffect; that is, ab1−ab2+ab3−ab4+… . 
Andrew is exploring different avenues regarding pokémon request. He performs q activities. In I-th activity Andrew trades li-th and ri-th pokémon. 
Note: q=0 in this rendition of the assignment. 
Andrew needs to know the maximal stregth of the military he can accomplish with the underlying pokémon position. He additionally has to know the maximal quality after every activity. 
Help Andrew and the pokémon, or group R will understand their dubious arrangement! 
Each test contains various experiments. 
The primary line contains one sure whole number t (1≤t≤103) meaning the quantity of experiments. Portrayal of the experiments follows. 
The principal line of each experiment contains two whole numbers n and q (1≤n≤3⋅105,q=0) indicating the quantity of pokémon and number of tasks individually. 
The subsequent line contains n unmistakable positive whole numbers a1,a2,… ,a (1≤ai≤n) meaning the qualities of the pokémon. 
I-th of the last q lines contains two positive whole numbers li and ri (1≤li≤ri≤n) signifying the files of pokémon that were traded in the I-th activity. 
It is ensured that the entirety of n over all experiments doesn’t surpass 3⋅105, and the whole of q over all experiments doesn’t surpass 3⋅105. 
For each experiment, print q+1 whole numbers: the maximal quality of armed force before the trades and after each trade. 
3 0 
1 3 2 
2 0 
1 2 
7 0 
1 2 5 4 3 6 7 
In third experiment we can assemble a military in such manner: [1 2 5 4 3 6 7], its quality will be 5−3+7=9.

Leave a Comment

17 − twelve =