Leaderboard
Showing:
Handle Score
@Ibrahim Nash 6454
@blackshadows 6380
@mb1973 5710
@Quandray 5245
@akhayrutdinov 5111
@saiujwal13083 5046
@sanjay05 3762
@kirtidee18 3709
@mantu_singh 3556
@marius_valentin_dragoi 3523
@sushant_a 3459
Complete Leaderboard
K Subarray Sum
Easy Accuracy: 66.69% Submissions: 1054 Points: 2

Given an integer array arr of size N and two integers K and M, the task is to find M largest sums of K sized subarrays. 

Input:
1. The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
2. The first line of each test case contains three integers N, K, and M.
3. The next line contains N space-separated integers.


Output: For each test case, print M space-separated integers (Print the sums from the maximum to minimum)

Constraints:
1. 1 <= T <= 100

2. 1 <= K <= N <= 104
3. 1 <= M <= N - K + 1
4. 1 <= arr[i] <= 105


Example:
Input:

2
5 2 3
10 11 10 11 12
5 5 1
1 2 3 4 5

 

Output:
23 21 21
15


Explanation:
Test Case 1:
2 sized subarray sum are {21, 21, 21, 21, 23}, We need to print 3 largest sums from maximum to minimum

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.

K Subarray Sum

Output Window