Advertisement
Dang_Quan_10_Tin

ISLAND HSGTPVinh L9 2019-2020

Jan 8th, 2022
932
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #define task "ISLAND"
  2.  
  3. #include <iostream>
  4. #include <cstdio>
  5.  
  6. using namespace std;
  7.  
  8. using ll = long long;
  9. using ld = long double;
  10.  
  11. constexpr int N = 3e6 + 5;
  12. int n, a[N], cnt[N];
  13.  
  14. void Read()
  15. {
  16.     cin >> n;
  17.  
  18.     for (int i = 1; i <= n; ++i)
  19.     {
  20.         cin >> a[i];
  21.         ++cnt[a[i]];
  22.     }
  23. }
  24.  
  25. void Solve()
  26. {
  27.     int ans(0);
  28.  
  29.     for (int i = 1; i < N; ++i)
  30.         ans += (cnt[i] + i - 1) / i;
  31.  
  32.     cout << ans;
  33. }
  34.  
  35. int32_t main()
  36. {
  37.     ios::sync_with_stdio(0);
  38.     cin.tie(0);
  39.     cout.tie(0);
  40.     if (fopen(task ".INP", "r"))
  41.     {
  42.         freopen(task ".INP", "r", stdin);
  43.         freopen(task ".OUT", "w", stdout);
  44.     }
  45.  
  46.     Read();
  47.     Solve();
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement