Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- const int N = 1e3 + 10;
- int n;
- int cnt[N];
- main()
- {
- cin >> n;
- for (int i = 1; i <= n; ++i)
- {
- int x;
- cin >> x;
- cnt[x]++;
- }
- ll ans = 0;
- for (int i = 0; i <= 1000; ++i)
- {
- ans += cnt[i] * (cnt[i] - 1) / 2;
- }
- ans += cnt[0] * (n - cnt[0]);
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement