# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1249983 | 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) {
int n = H.size();
llo ans = 0;
fn(i,0,n-1) fn(j,i+1,n-1) fn(k,j+1,n-1){
vector<int> h = {H[i], H[j], H[k]};
vector<int> d = {j - i, k - j, k - i};
sort(h.begin(), h.end());
sort(d.begin(), d.end());
if(h == d) ans++;
}
return ans;
}