for _ in range(int(input())):
X = int(input())
A = list(map(int, input().split()))
balance = 0
prev_index = 1
next_index = 0
index = 2
current = 0
maxx = 0
while index <= X:
for i in range(index - 1, X):
current = (A[i] - (i + 1)) + (prev_index - 1)
if current > maxx:
maxx = current
current = 0
balance += maxx
next_index = i + 1
prev_index = next_index
index += 1
maxx = 0
print(balance)
I would be appreciated if you could help me on this.
Just asking if you knew what the question meant. I know that the technique is Greedy, and this one doesn’t look like bigger is always better, so made the code like this. Can you help me like in at least choosing the formula I have to write?