KCON - Editorial

can someone pls explain why have we made 2A array in this question and how have we arrived at the logic?

https://www.codechef.com/viewsolution/38153405

Please help me figure out the mistake in the code.
Thanks in advance.

more good for,
1
3 3
7 -8 4

Superb explanation! From the ground up.

1 Like

please provide more clear editorials

What’s wrong in my code ?? i am using kadena’s algo .
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lli long long int
#include
using namespace std;
lli maxsubarraysum(vectorarr,lli n)
{
int max_end_h=0;
int max_so_far=INT_MIN;
for(int i=0;i<n;i++)
{
max_end_h+=arr[i];
if(max_end_h<arr[i])
max_end_h=arr[i];
if(max_so_far<max_end_h)
max_so_far=max_end_h;
}
return max_so_far;
}
int main()
{
lli t;
cin>>t;
while(t–)
{
lli n,k;
cin>>n>>k;
vectorarr,brr;
for(lli i=0;i<n;i++)
{
lli x;
cin>>x;
arr.push_back(x);
}
for(lli i=0;i<k;i++)
{
for(lli j=0;j<n;j++)
brr.push_back(arr[j]);
}
lli maxval=maxsubarraysum(brr,n*k);
cout<<maxval<<endl;
}
}