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
33
34
35
#include "kanapka.h"
#include "message.h"

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

long long sum, sub, minsub;

int main() {
  long long N = GetN(), i, j;
  if(MyNodeId()==0){
    /*if (N == 1)
      cout << max(0ll, GetTaste(0)) << endl;
    else
      cout << max(max(GetTaste(0), GetTaste(N - 1)),
              max(0ll, GetTaste(0) + GetTaste(N - 1))) << endl;*/
              
     //cout << 42 << endl;
     
     for(i=0; i<N; i++){
        sum+=GetTaste(i);
     }
     for(i=0; i<N; i++){
        sub=0;
        for(j=i; j<N; j++){
          sub+=GetTaste(j);
          minsub=min(minsub, sub);
        }
     }
     //cout << sum << ' ' << minsub << ' ' << sum-minsub << endl;
     cout << sum-minsub << endl;
  }
  return 0;
}