D_L3

SDA - 2018 2019 - test5 - task 1

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