Advertisement
sherry_ahmos

Untitled

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