fork download
  1. #include <iostream>
  2. #include <deque>
  3. #include <limits>
  4. #include <algorithm>
  5. #include <functional>
  6. using namespace std;
  7.  
  8. void printDeque(deque<int> &v, int iLength) {
  9. int iTemp{int(v.size()) - iLength - 1};
  10. for (int i = 0; i < iTemp; i++) {
  11. deque<int>::iterator first = next(v.begin());
  12. deque<int>::iterator last = next(v.begin() + i + iLength);
  13. int iMax = *max_element(first, last);
  14. cout << iMax << " ";
  15. }
  16. cout << endl;
  17. }
  18.  
  19. int main()
  20. {
  21. deque<int> arr;
  22.  
  23. int iTestCases {0};
  24. int iSize {0};
  25. int iElement {0};
  26. cin >> iTestCases;
  27. int iArraySize{0}, iSubSize {0};
  28. int i {0};
  29. deque<int> result;
  30. while (iTestCases--) {
  31. cin >> iArraySize >> iSubSize;
  32. arr.erase(arr.begin(), arr.end());
  33. arr.resize(iArraySize);
  34. i = 0;
  35. for (auto &i : arr)
  36. cin >> i;
  37. printDeque(arr, iSubSize);
  38. }
  39. }
  40.  
  41. // Run program: Ctrl + F5 or Debug > Start Without Debugging menu
  42. // Debug program: F5 or Debug > Start Debugging menu
  43.  
  44. // Tips for Getting Started:
  45. // 1. Use the Solution Explorer window to add/manage files
  46. // 2. Use the Team Explorer window to connect to source control
  47. // 3. Use the Output window to see build output and other messages
  48. // 4. Use the Error List window to view errors
  49. // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
  50. // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
  51.  
Success #stdin #stdout 0.01s 5300KB
stdin
2
5 2
3 4 6 3 4
7 4
3 4 5 8 1 4 10
stdout
6 6 
8 8