Gửi bài giải
Điểm:
1,00 (OI)
Giới hạn thời gian:
1.0s
Giới hạn bộ nhớ:
256M
Input:
stdin
Output:
stdout
Nguồn bài:
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Given an array of length n, find the subarray of length k which have largest sum of values.
Input
The first line contains two integers n and k (k ≤ n ≤ 105)
The second line contains n integers which are elements of the array, each integer has absolute values not exceed 106, respectively.
Output
The sum of values in the subarray
Sample
Sample Input
6 3
-3 -4 -1 -2 -4 -1
Sample Output
-7
There are 4 large test cases and 16 small test cases. Student can use two nested loops to solve first 16 testcases and earn 80% score.
Bình luận