# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1250730 | JelalTkm | Triple Peaks (IOI25_triples) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
// #define int long long int
// const int N = 5e5 + 10;
// const int md = 1e9 + 7;
// const int INF = 1e18;
long long count_triples(vector<int> h) {
int n = (int) h.size();
if (n <= 100) {
long long ans = 0;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
for (int k = j + 1; k < n; k++) {
multiset<int> s;
s.insert(j - i);
s.insert(k - i);
s.insert(k - j);
multiset<int> s1;
s1.insert(h[i]);
s1.insert(h[j]);
s1.insert(h[k]);
if (s == s1)
ans++;
}
}
}
return ans;
}
return 0ll;
}
// int32_t main(int32_t argc, char *argv[]) {
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// int T = 1;
// // cin >> T;
// while (T--) {
// vector<int> h = {4, 1, 4, 3, 2, 6, 1};
// cout << count_triples(h) << '\n';
// }
// return 0;
// }