david12457899

cses Distinct Numbers

May 14th, 2021
702
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "bits/stdc++.h"
  2.  
  3. const int max = 1000000007;
  4.  
  5. int main()
  6. {
  7.     int n, counter = 0;
  8.     std::cin >> n;
  9.    
  10.  
  11.     std::vector<int> values(n);
  12.  
  13.     for (int i = 0; i < n; i++)
  14.     {
  15.         std::cin >> values[i];
  16.     }
  17.  
  18.     std::sort(values.begin(), values.end());
  19.  
  20.     for (int i = 0; i < n - 1; i++)
  21.     {
  22.        
  23.         if (values[i] != values[i + 1])
  24.         {
  25.             counter++;
  26.         }
  27.     }
  28.  
  29.     std::cout << ++counter;
  30.     return 0;
  31. }
RAW Paste Data