Advertisement
MohamedAbdel3al

1. Unique Elements

Sep 30th, 2021
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std ;
  4. #define sz(s) int(s.size())
  5. #define all(s) s.begin() , s.end()
  6. #define imin INT_MIN
  7. #define imax INT_MAX
  8. #define ll long long
  9. #define ull unsigned long long
  10. #define Time cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " Secs" << "\n";
  11. #define cin(v) for (auto& i : v) cin >> i ;
  12. #define pb(x) push_back(x)
  13. #define getline(s) getline(cin >> ws, s)
  14. #define Mod 1'000'000'007
  15. #define INF 2'000'000'000
  16. #define Num_of_Digits(n) ((int)log10(n)+1)
  17.  
  18. void ABDEL3AL () {
  19. ios_base::sync_with_stdio(false); cin.tie(nullptr) , cout.tie(nullptr) ;
  20. #ifndef ONLINE_JUDGE
  21. freopen("input.txt" , "r" , stdin) , freopen("output.txt" , "w" , stdout) ;
  22. #endif
  23. Time
  24. }
  25.  
  26.  
  27. int main() {
  28. ABDEL3AL() ;
  29. int n ; cin >> n ;
  30. vector <ll> v(n) ;
  31. cin(v) ;
  32. sort (all(v)) ;
  33. for (int i = 1; i < n; i++) {
  34. if (v[i] == v[i - 1]) v.erase(remove(v.begin() , v.end() , v[i]), v.end());
  35. }
  36. cout << sz(v) ;
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement