General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
200030913 Practice:
vjudge3
1744F - 21 Python 3 Accepted 451 ms 13940 KB 2023-03-31 21:02:40 2023-03-31 21:02:41
→ Source
for _ in range(int(input())):
    n = int(input())
    p = list(map(int, input().split()))
    pinv = [0] * n
    for i in range(n): pinv[p[i]] = i
    idxmin, idxmax = pinv[0], pinv[0]
    ans = 1
    for w in range(2, n+1):
        if w % 2 == 1:
            idxmin, idxmax = min(idxmin, pinv[w//2]) ,max(idxmax, pinv[w//2])
        ans += max(0, min(idxmin, n-w) - max(idxmax+1-w, 0) + 1)
    print(ans)
  		 	  			   							 				 	 	
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details