fork download
  1. #include <vector>
  2. #include <algorithm>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int main() {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. vector<int>ciag;
  10. vector<int>::iterator it;
  11. int n,k;
  12. cin >> n;
  13. for(int i=0;i<n;++i){
  14. cin >> k;
  15. it=lower_bound(ciag.begin(),ciag.end(),k);
  16. ciag.insert(it, k);
  17. for(int j=0;j<ciag.size();++j){
  18. cout << ciag[j] << ' ';
  19.  
  20. }
  21. cout << endl;
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0s 5300KB
stdin
9
3 3 4 5 6 5 6 5 5
stdout
3 
3 3 
3 3 4 
3 3 4 5 
3 3 4 5 6 
3 3 4 5 5 6 
3 3 4 5 5 6 6 
3 3 4 5 5 5 6 6 
3 3 4 5 5 5 5 6 6