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
50
51
52
53
#include <bits/stdc++.h>
#include "kanapka.h"
#include "message.h"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long instance=MyNodeId();
    long long instances=NumberOfNodes();
    long long n=GetN();
    long long to_each=n/instances;
    long long l,r;
    long long curr_sum,taste,min_sum2=0,min_pref=0,min_suf=0,min_sum=0,tot_sum=0;
    /*l=to_each*(instance);
    r=min(to_each*(instance+1),n);
    curr_sum=0;
    for(long long i=l;i<r;i++)
    {
        taste=GetTaste(i);
        min_sum2=min(taste,taste+min_sum2);
        min_sum=min(min_sum,min_sum2);
        curr_sum+=taste;
        min_pref=min(min_pref,curr_sum);
    }
    curr_sum=0;
    for(long long i=r-1;i>=l;i--)
    {
        curr_sum+=GetTaste(i);
        min_suf=min(min_suf,curr_sum);
    }
    tot_sum=curr_sum;*/
    if(instance!=0)
    {
        //Receive(instance-1);
        //tot_sum+=GetLL(instance-1);
        //min_sum=min(min_sum,GetLL(instance-1));
        //min_sum=min(min_sum,GetLL(instance-1)+min_pref);
    }
    if(instance!=n-1)
    {
        PutLL(instance+1,tot_sum);
        //PutLL(instance+1,min_sum);
        //PutLL(instance+1,min_suf);
        //Send(instance+1);
    }
    else
    {
        cout<<tot_sum-min_sum;
    }
}