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
#include "message.h"
#include <bits/stdc++.h>
#include "kanapka.h"

using namespace std;

typedef long long ll;

int main()
{
	if(MyNodeId() != 0)return 0;

	int n = GetN();
	vector<ll>lewa(n + 2),prawa(n + 2);

	ll cur = 0;
	for (int i = 1; i <= n; ++i)
	{
		cur += GetTaste(i - 1);
		lewa[i] = max(lewa[i - 1] , cur);
	}

	cur = 0;
	for(int i = n; i >= 1 ; i --)
	{
		cur += GetTaste(i - 1);
		prawa[i] = max(prawa[i + 1], cur);
	}
	
	ll res = 0;

	for(int i = 0 ; i <= n ; i++)
	{
		res = max({res,lewa[i],prawa[i + 1], lewa[i] + prawa[i + 1]});
	}

	cout << res;

	return 0;
}