# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1249978 | liamislazy | Triple Peaks (IOI25_triples) | C++20 | 0 ms | 0 KiB |
#include "triples.h"
#include <bits/stdc++.h>
#define el '\n'
typedef long long llo;
#define fn(i,a,b) for (int i = a; i <= b; i++)
#define rn(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
long long count_triples(std::vector<int> H) {
llo ans = 0;
fn(i,0,n-1) fn(j,i+1,n-1) fn(k,j+1,n-1){
vector<int> heights = {h[i], h[j], h[k]};
vector<int> dists = {j - i, k - j, k - i};
sort(heights.begin(), heights.end());
sort(dists.begin(), dists.end());
if(heights == dists) ans++;
}
cout << ans;
}