?
# | Author | Problem | Lang | Verdict | Time | Memory | Sent | Judged | |
---|---|---|---|---|---|---|---|---|---|
257016698 |
Practice: Traverser_Steal69 |
1744F - 21 | C++17 (GCC 7-32) | Accepted | 281 ms | 1628 KB | 2024-04-17 11:48:38 | 2024-04-17 11:48:38 |
#include<bits/stdc++.h> using namespace std; const int N=2e5+10; long long T,p[N],n,l,r,re,me,i,x,L; int main(){ for(cin>>T;T--;){ cin>>n; for(i=1;i<=n;i++)cin>>x,p[x]=i;l=r=p[0],re=1,me=0; for(L=2;L<=n;L++)me=(L-1)/2,l=min({l,p[me],n+1-L}),r=max({r,p[me],L}),re+=max(0ll,L-r+l); cout<<re<<'\n'; } }
?
?
?
?