Help with "K-concatenation" (KCON)

Description : First I find the total(tot) of the given array, and also the maximum sum(max_sum) of sub-arrays of the array. If the total is greater than 0, then I add total of (k - 1) arrays to the current sum (max_sum += tot*(k - 1). Else if the total (tot) is less than or equal to 0, then I concatenate the array with itself , then find the max_sum for that array.

I’m getting partial correct and, two out of four test cases in the second subtask passes. Please help me find out the mistake, by giving any test case where my code fails, or point out the mistake in my code. (I guess I’ve also taken care of Integer Overflow).

Link to code : Solution

Try

5 2
-10 5 5 5 -10

I’m getting 15 as answer.

I messed up. I meant

1
5 2
10 -5 -5 -5 10

Oh thank you so much…! I figured out where I’m wrong…