The Nebula Scanner
View as PDFThe Nebula Scanner
Aboard the ISS Prometheus, the nebula scanner captures energy readings every second stored in an array. Scientists want to analyse the peak energy in every consecutive window of seconds — a sliding maximum across the entire reading sequence.
Your Task
Given energy readings and window size
, output the maximum value in each consecutive window of size
. There are
windows total.
Input Specification
- Line 1:
— number of scan sequences.
- Each sequence:
- Line 1: two integers
and
- Line 2:
space-separated integers
- Line 1: two integers
Output Specification
For each sequence print space-separated integers: the maximum of each
window.
Sample Input
2
8 3
1 3 -1 -3 5 3 6 7
5 2
4 3 5 1 2
Sample Output
3 3 5 5 6 7
4 5 5 2
Constraints
Comments