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
32
#include "maklib.h"
#include "message.h"

#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int i,j,size;
  long long maks=0,pmaks=0;
  size=Size();
  if (MyNodeId()==0){
    for (i=1;i<=size;i++){
        pmaks += ElementAt(i) ;
        if (pmaks>maks)maks=pmaks;
        else if (pmaks<0) pmaks=0;
   }
   cout <<maks<<endl;
   }
/*  if (MyNodeId()==1){
  for (i=size;i>0;i--)
      cout << "1-->> " << ElementAt(i) <<endl;
   }
 */  	
/*  if (Size() < 2)
    cout << max(0, ElementAt(1)) << endl;
  else
    cout << max(max(ElementAt(1), ElementAt(2)), max(0, ElementAt(1) + ElementAt(2))) << endl;
*/

  return 0;
}