General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
179450030 Practice:
sachin_24063
1744F - 21 C++17 (GCC 7-32) Accepted 249 ms 780 KB 2022-11-05 18:17:52 2022-11-05 18:17:52
→ Source
#include <bits/stdc++.h>
using namespace std;
 
void go(){
	int n;
	cin>>n;
	int p[n+5];
	for(int i=1;i<=n;i++) {
		int x;
		cin>>x;
		p[x]=i;
	}
	int l=p[0],r=p[0];
	int64_t ans=1;
	for(int i=2;i<=n;i++){
		if(i&1){
			int x=i/2;
			l=min(l,p[x]), r=max(r,p[x]);
		}
		int d1=max(r-i+1,1), d2=min(n,l+i-1);
		d2-=i-1;
		if(d2>=d1) ans+=d2-d1+1;
	}
	cout<<ans<<endl;
	
}
 
int main() {
	int t;
	cin>>t;
	while(t--) go();
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details