Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. typedef long long ll;
  5. const int N = 1e3 + 10;
  6.  
  7. int n;
  8. int cnt[N];
  9.  
  10. main()
  11. {
  12. cin >> n;
  13. for (int i = 1; i <= n; ++i)
  14. {
  15. int x;
  16. cin >> x;
  17. cnt[x]++;
  18. }
  19.  
  20. ll ans = 0;
  21.  
  22. for (int i = 0; i <= 1000; ++i)
  23. {
  24. ans += cnt[i] * (cnt[i] - 1) / 2;
  25. }
  26. ans += cnt[0] * (n - cnt[0]);
  27. cout << ans;
  28.  
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement