fork download
  1. #include <iostream>
  2. #include <cmath>
  3. #include <algorithm>
  4. #include <string>
  5. #include <deque>
  6. #define ll long long
  7. using namespace std;
  8. const int N = 1e5 + 5;
  9. int main()
  10. {
  11. int n , d ;
  12. cin >> n >> d;
  13. deque<int>de(n);
  14. for(int i = 0 ; i < n ; i++)
  15. cin >> de[i];
  16. while(d != 0)
  17. {
  18. int x = de[0];
  19. de.push_back(x);
  20. de.pop_front();
  21. d--;
  22. }
  23. for(int i = 0 ; i < n + d ; i++)
  24. cout << de[i] << " ";
  25. }
  26.  
Success #stdin #stdout 0.01s 5568KB
stdin
5 4
1 2 3 4 5
stdout
5 1 2 3 4