# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1250287 | alex0152 | Triple Peaks (IOI25_triples) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
const int nMax=2e5+5;
int t,n,m,a,b,c,d,x,y,z,k,cnt,ans,sum,H[100];
int main()
{
cin>>t;
cin>>n;
for(int i=0; i<n; ++i)
cin>>H[i];
long long ans=0;
long long a[3],b[3];
for(int i=0; i<n-2; ++i)
for(int j=i+1; j<n-1; ++j)
for(int p=j+1; j<n; ++p)
{
a[0]=H[i],a[1]=H[j],a[2]=H[p];
b[0]=j-i,b[1]=p-i,b[2]=p-j;
sort(a,a+3);
sort(b,b+3);
if(a[0]==b[0] && a[1]==b[1] && a[2]==b[2])
ans++;
}
cout<<ans<<'\n';
}