# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1250296 | alex0152 | Triple Peaks (IOI25_triples) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
const int nMax=2e5+5;
long long count_triples(std::vector<int> H)
{
int n=H.size(),a[3],b[3];
long long ans=0;
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++;
}
return ans;
}