Advertisement
Ahmed_Negm

Untitled

Feb 21st, 2022
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. #include<iomanip>
  4. #include<algorithm>
  5. #include<cstdlib>
  6. #include<cstring>
  7.  
  8. #define ll long long
  9. #define sz(x) int(x.size())
  10. using namespace std;
  11.  
  12. void Fast_IO(){
  13.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  14.     #ifndef ONLINE_JUDGE
  15.         freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  16.     #endif
  17. }
  18.  
  19. ll count(ll arr[],ll n){
  20.     sort(arr,arr+n);
  21.     ll counter =1;
  22.     for(ll i =1;i<n;i++){
  23.         if(arr[i]!=arr[i-1]) counter++;
  24.     }
  25.     return counter;
  26. }
  27.  
  28.  
  29.  
  30.  
  31. int main(){
  32.     Fast_IO();
  33. int t =1;
  34. //cin>>t;
  35. while(t--){
  36. ll n; cin>>n;
  37. ll arr[n];
  38. for(ll i =0; i<n; i++) cin>>arr[i];
  39. cout<<count(arr,n);
  40.  
  41.  
  42.  
  43.  
  44.  
  45. }
  46. return 0;
  47. }  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement