1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "maklib.h"//!ichna
#include "message.h"
#include <iostream>
using namespace std;
//int t[8]={4, 1, -3, -3, 3, -2, 6, -10};
//int const MAX=1000000000;
int kadane(int n)
{
    int maxi=0, suma=0;
    for (int i=0; i<n; i++)
    {
        suma=suma+ElementAt(i+1);//!;
        if (suma>maxi)
        {
            maxi=suma;
        }
        if (suma<0)
        {
            suma=0;
        }
    }
    return maxi;
}
int main()
{
    ios_base::sync_with_stdio(0);

    if (MyNodeId()==0)
        cout<<kadane(Size());//!kadane(Size());
    return 0;
}