#include <bits/stdc++.h> #include <unistd.h> #define ll long long #define ull unsigned long long #define inf 1000000007 #define inf16 0x3f3f3f3f #define INF 1000000000000000007LL #define VI vector<int> #define VPII vector<pair<int, int> > #define VLL vector<ll> #define PII pair<int, int> #define PLL pair<ll, ll> #define st first #define nd second #define pb push_back #define mp make_pair #define eb emplace_back #define endl '\n' #define ALL(c) (c).begin(), (c).end() using namespace std; #include <message.h> #include <kanapka.h> const int S = 5e7; int n, id; ll pref, max_pref, suf, max_suf; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(NULL); PutInt(0, 0); Send(0); if(MyNodeId()==0) { for(int i = 0; i < NumberOfNodes(); ++i) { Receive(i); GetInt(i); } } if(!MyNodeId()) cout << -1; return 0; n = GetN(); id = MyNodeId(); for(int i = S*id; i < S*(id+1); ++i) { pref += i<n?GetTaste(i):0; max_pref = max(max_pref, pref); } }
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 54 55 56 57 58 59 60 61 62 63 64 65 | #include <bits/stdc++.h> #include <unistd.h> #define ll long long #define ull unsigned long long #define inf 1000000007 #define inf16 0x3f3f3f3f #define INF 1000000000000000007LL #define VI vector<int> #define VPII vector<pair<int, int> > #define VLL vector<ll> #define PII pair<int, int> #define PLL pair<ll, ll> #define st first #define nd second #define pb push_back #define mp make_pair #define eb emplace_back #define endl '\n' #define ALL(c) (c).begin(), (c).end() using namespace std; #include <message.h> #include <kanapka.h> const int S = 5e7; int n, id; ll pref, max_pref, suf, max_suf; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(NULL); PutInt(0, 0); Send(0); if(MyNodeId()==0) { for(int i = 0; i < NumberOfNodes(); ++i) { Receive(i); GetInt(i); } } if(!MyNodeId()) cout << -1; return 0; n = GetN(); id = MyNodeId(); for(int i = S*id; i < S*(id+1); ++i) { pref += i<n?GetTaste(i):0; max_pref = max(max_pref, pref); } } |