Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize 03
- #include <bits/stdc++.h>
- using namespace std;
- const int m = 2e4 + 1;
- int main() {
- int n;
- cin >> n;
- vector<int> a(n);
- for (auto &el : a) cin >> el;
- vector<int> cnt(m);
- for (auto el : a) cnt[el]++;
- long long ans = 0;
- for (int i = 0; i < n; ++i) {
- cnt[a[i]]--;
- for (int j = 0; j < i; ++j) {
- ans += cnt[a[i] + a[j]];
- }
- }
- cout << ans << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement