Consider a dungeon consisting of $$$n$$$ levels, numbered from $$$1$$$ to $$$n$$$. You are given an array $$$a = a_1, a_{2}, ..., a_{n}$$$, where each element $$$a_{i}$$$ represents the number of points that can be scored at level $$$i$$$.
Initially, your score is $$$0$$$.
You have two available operations at every level from $$$1$$$ to $$$n$$$ :
Note that you are allowed to apply exactly one of the two options above at each level.
Find the maximum possible score you can obtain.
In the first line of the input You'll be given $$$t$$$ the number of testcases.
In the first line of each next $$$t$$$ testcases You'll be given an integer $$$n$$$ which shows the number of levels.
In the second line of each testcase You'll be given an array of length $$$n$$$.
$$$1 \le t \le 10^4$$$.
$$$1 \le n \le 2 \cdot 10^5$$$.
$$$1 \le |a_i| \le 10^9$$$.
It is guaranteed that sum of $$$n$$$ overall testcases does not exceed $$$2 \cdot 10^5$$$.
Print the maximum score you can achieve.
45-1 -1 -1 2 -135 5 62-1000000000 15-2 -2 3 4 -1
-2 16 0 4
You are given an array of positive integers of length $$$n$$$.
You need to find a value $$$x$$$ such that sum of $$$|a_i - x - i|$$$ over all $$$1 \le i \le n$$$ is minimized (This is declared as the $$$summation$$$ of the array).
Now your task is to print the minimum $$$summation$$$.
In the first line of input You'll be given a number $$$n$$$ which shows the length of the array.
In the second line You'll receive an array $$$a$$$ of positive integers.
$$$1 \le n \le 10^5$$$.
$$$1 \le a_i \le 10^9$$$.
Print the minimum $$$summation$$$ possible.
5 2 3 4 6 8
3
There's an array of size $$$10^{18}$$$ which every element of the array is $$$1$$$. After each second, Every element of the array becomes the prefix sum of it's position, it means for example at a second the array is $$$a_{1}, a_{2}, a_{3}, ....$$$ in the next second the array becomes $$$a_{1}, a_{1} + a_{2}, a_{1} + a_{2} + a_{3}, ....$$$ . Now your task is to find the $$$n_{th}$$$ element of the array after $$$k$$$ seconds.
In the first line of input, You'll be given a number $$$t$$$ which shows the number of testcases.
In the next $$$t$$$ lines you'll be given two integers $$$n$$$ and $$$k$$$.
$$$1 \le t \le 10^{5}, 1 \le n \le 10^{5}, 1 \le k \le 10^5$$$.
Note that for each testcases the initial array is filled with $$$1$$$.
As the answer can be large print the answer modulo $$$10^9 + 7$$$.
32 11 32 4
2 1 5
Testcase $$$1$$$ :
The array at second $$$0 : 1, 1, 1, 1, 1, 1, ...$$$
The array at second $$$1 : 1, 2, 3, 4, 5, 6, ...$$$
The array at second $$$2 : 1, 3, 6, 10, 15, 21, ...$$$
A comic number is defined as a positive integer which is divisible by the floor of its cubic root (the third root). Example : $$$68$$$ is divisible by $$$\lfloor \sqrt[3]{68} \rfloor = \lfloor 4.081 \rfloor = 4$$$.
Given two positive integers $$$l$$$ and $$$r$$$, $$$(l \le r)$$$, find the total number of comic numbers between them (inclusive of $$$l$$$ and $$$r$$$ both).
The first line of the input contains a single integer $$$t$$$ - the number of testcases.
Each testcase consists of one line containing two positive integers $$$l$$$ and $$$r$$$.
$$$1 \le t \le 10^5$$$.
$$$1 \le l \le r \le 10^{18}$$$.
For each testcase, Print the total number of comic numbers between $$$l$$$ and $$$r$$$, $$$[l, r]$$$ (inclusive) in a newline.
21 10000000000000000003 81
1500002499997 33
You're given a grid of size $$$n \cdot m$$$, Each cell of the grid contains "0", "1", or "?". For every "?" We should randomly choose "0" or "1" and put it in there. Now your task is to find the probability that there aren't two adjacent "1" in the grid, For cell $$$(i, j)$$$, all cells $$$(i + 1, j), (i - 1, j), (i, j + 1), (i, j - 1)$$$ are counted as it's adjacent cells. Print the answer modulo $$$998244353$$$.
In the first line of input, You'll receive two integers $$$n$$$ and $$$m$$$ which $$$n$$$ shows the number of rows and $$$m$$$ shows the number of columns.
$$$1 \le n, m \le 15$$$.
In the second line you'll receive a grid of size $$$n \cdot m$$$ which only contains of "?", "0" or "1".
Print the answer modulo $$$998244353$$$.
2 5 0?100 1000?
499122177
2 2 ?1 01
0
This is the easy version of the problem. The only difference between the two versions is the constraint on $$$n$$$.
You have an array of length $$$n$$$, We declare function $$$f(x)$$$ for a non-empty subsequence of the array as the minimum number of moves needed to change the subsequence's elements to make the subsequence $$$palindrome$$$. The move is defined as follows.
Now your task is to find sum of $$$f(x)$$$ for all non-empty subsequences of the array.
In the first line of input You'll be given number $$$n$$$ which shows the length of the array.
In the second line You'll receive the array.
$$$1 \le n \le 10^3$$$.
$$$1 \le a_i \le n$$$.
Print an integer representing the sum of $$$f(x)$$$ for all non-empty subsequences, as the answer may be large, Print it modulo $$$998244353$$$.
5 4 2 4 3 5
30
10 2 2 1 1 3 2 3 4 1 3
1969
5 2 5 3 1 4
32
This is the hard version of the problem. The only difference between the two versions is the constraint on $$$n$$$.
You have an array of length $$$n$$$, We declare function $$$f(x)$$$ for a non-empty subsequence of the array as the minimum number of moves needed to change the subsequence's elements to make the subsequence $$$palindrome$$$. The move is defined as follows.
Now your task is to find sum of $$$f(x)$$$ for all non-empty subsequences of the array.
In the first line of input You'll be given number $$$n$$$ which shows the length of the array.
In the second line You'll receive the array.
$$$1 \le n \le 10^5$$$.
$$$1 \le a_i \le n$$$.
Print an integer representing the sum of $$$f(x)$$$ for all non-empty subsequences, as the answer may be large, Print it modulo $$$998244353$$$.
5 4 2 4 3 5
30
10 2 2 1 1 3 2 3 4 1 3
1969
5 2 5 3 1 4
32