Advertisement
tumaryui

Untitled

Sep 12th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. main() {
  5. vector<int> a = {0, 0, 6, 4, 5, 3, 1, 2, 1, 2};
  6. vector<int> cnt(7);
  7. vector<int> pref(7);
  8. for(int i = 0; i < 10; i++) {
  9. cnt[a[i]]++;
  10. }
  11. for(int i = 0; i < 7; i++) {
  12. if(i > 0) pref[i] = pref[i - 1];
  13. pref[i] += cnt[i];
  14. }
  15. vector<int> res(10);
  16. for(int i = 9; i >= 0; i--) {
  17. res[pref[a[i]] - 1] = a[i];
  18. pref[a[i]]--;
  19. }
  20. for(auto it: res) {
  21. cout << it << " ";
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement