Submit | All submissions | Best solutions | Back to list |
EISARR - Subarray |
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
Input |
Output |
6 3 -3 -4 -1 -2 -4 -1 |
-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.
Added by: | Ha Minh Ngoc |
Date: | 2019-12-15 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |