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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include "kanapka.h"
#include "message.h"


using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
	//cerr << MyNodeId();
	if(MyNodeId() == 0)
	{
		ios_base::sync_with_stdio(0);
		ll N,a,suma;
		ll maxloc = 0, maxglob = 0;
		//std::vector<ll> v;
		//cin >> N;
		N = GetN();
		//cerr << N<<"\n\n";

		for (int i = 0; i < N; ++i)
		{
		 	//cin >> a;
		 	a = GetTaste(i);
		 	//cerr << a<<"\n";
		 	suma +=a;
		 	a = -a;
		 	if (!i)maxglob = a;
		 	maxloc = max(a, maxloc + a);
		 	maxglob = max(maxglob, maxloc);

		 	//v.push_back(a);
		} 

		//printf("%I64d",suma + maxglob );
		cout << suma + maxglob<<"\n";
	}


	

	return 0;
}