D_L3

SDA - 2021-2022 - test5 - task 2

Dec 11th, 2023
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. #include <unordered_map>
  7.  
  8. using namespace std;
  9.  
  10.  
  11. int main() {
  12. unordered_map<long long, int> counter;
  13. int n;
  14. long long num;
  15.  
  16. cin >> n;
  17.  
  18. for(int i = 0; i < n; i++){
  19. cin >> num;
  20. counter[num]++;
  21. }
  22.  
  23. int sum = 0;
  24. for(auto i : counter){
  25. if(i.second % 2 == 1)
  26. sum += (i.second * i.first);
  27. }
  28. cout << sum;
  29. return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment