Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int solve() {
- int n;
- cin >> n;
- vector<int> v(n);
- for (int i = 0; i < n; ++i)
- cin >> v[i];
- sort(v.begin(), v.end());
- int res = 0;
- for (int i = 0; i < v.size(); ++i) {
- if (i != 0 && v[i-1] == v[i]) continue;
- for (int j = i+1; j < v.size(); ++j) {
- if (v[j-1] == v[j] && i + 1 != j) continue;
- for (int k = j+1; k < v.size(); ++k) {
- if (v[k-1] == v[k] && j + 1 != k) continue;
- if (v[k] < v[i] + v[j]) res++;
- }
- }
- }
- return res;
- }
- int main() {
- int t;
- cin >> t;
- for (int i = 0; i < t; ++i)
- {
- cout << "Case #" << i+1 << ": " << solve() << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement