# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1249782 | kduckp | Triple Peaks (IOI25_triples) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
long long count_triples(vector<int> H) {
long long res = 0;
int n = H.size();
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
for (int k = j + 1; k < n; k++) {
vector<int> height = {H[i], H[j], H[k]};
vector<int> dist = {j - i, k - i, k - j};
sort(height.begin(), height.end());
sort(dist.begin(), dist.end());
if (height == dist) res++;
}
return res;
}