Gửi bài giải
Điểm:
2,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
You are given an array of integers nums. There is a sliding window of size ~k~ that moves from the leftmost side of the array to the rightmost side. You can only see the ~k~ numbers within the window. Each time the sliding window moves one position to the right. Your task is to return the maximum number in the sliding window after each move.
INPUT
- Line 1: Two integers, ~n~ (the number of elements in the array) and ~k~ (the size of the sliding window).
- Line 2: ~n~ integers representing the array
OUTPUT
- One line containing ~n - k + 1~ integers, where each integer is the maximum number in the window that starts at that position.
CONSTRAINTS
- ~1 \leq n \leq 10^5~
- ~10^4 \leq nums[i] \leq 10^4~
- ~1 \leq k \leq n~
INPUT
8 3
1 3 -1 -3 5 3 6 7
OUTPUT
3 3 5 5 6 7
Bình luận