# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1250263 | kaloyan | Triple Peaks (IOI25_triples) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
long long count_triples(std::vector<int> H)
{
int N = H.size();
long long counter = 0;
for(int i = 0 ; i < N - 2 ; ++i)
{
for(int j = i + 1 ; j < N - 3 ; ++j)
{
for(int k = j + 1 ; k < N - 4 ; ++k)
{
vector<int> A = { j - i, k - i, k - j };
vector<int> B = { H[i], H[j], H[k] };
sort(A.begin(), A.end());
sort(B.begin(), B.end());
if(A == B) counter++;
}
}
}
return counter;
}