Advertisement
MohamedAbdel3al

V. Frequency Array

Sep 12th, 2021
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std ;
  4. #define sz(s) int(s.size())
  5. typedef long long ll ;
  6.  
  7. void ABDEL3AL () {
  8. ios_base::sync_with_stdio(false); cin.tie(nullptr) , cout.tie(nullptr) ;
  9. #ifndef ONLINE_JUDGE
  10. freopen("input.txt" , "r" , stdin) , freopen("output.txt" , "w" , stdout) ;
  11. #endif
  12. }
  13.  
  14. int main() {
  15. ABDEL3AL() ;
  16. int n , m ;
  17. cin >> n >> m ;
  18. int arr[n] , freq[m + 1] ;
  19. memset(freq , 0 , sizeof (freq)) ;
  20. for (int i = 0; i < n; i++)
  21. cin >> arr[i] , freq[arr[i]]++ ;
  22. for (int i = 1; i <= m; i++)
  23. if (freq[i]) cout << freq[i] << "\n" ;
  24.  
  25.  
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement