#include <iostream> #include "message.h" #include "kanapka.h" using namespace std; int main(){ long long n = GetN(); long long smacznosciowosc = 0; for(int i=MyNodeId(); i<n; i+=NumberOfNodes()) { smacznosciowosc+=GetTaste(i); } if(MyNodeId() > 0) { PutLL(0, smacznosciowosc); Send(0); } else { for (int i=1; i<NumberOfNodes(); i++) { Receive(i); smacznosciowosc += GetLL(i); } } //Teraz mam dobry smak calej kanaperki long long suma = 0, aktual = 0; if(MyNodeId()==0) { for(int i=0; i<n; i++) { aktual += GetTaste(i); if(aktual > 0) { aktual = 0; } else { suma = min(aktual, suma); } } cout << smacznosciowosc - suma << endl; } return 0; }
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 | #include <iostream> #include "message.h" #include "kanapka.h" using namespace std; int main(){ long long n = GetN(); long long smacznosciowosc = 0; for(int i=MyNodeId(); i<n; i+=NumberOfNodes()) { smacznosciowosc+=GetTaste(i); } if(MyNodeId() > 0) { PutLL(0, smacznosciowosc); Send(0); } else { for (int i=1; i<NumberOfNodes(); i++) { Receive(i); smacznosciowosc += GetLL(i); } } //Teraz mam dobry smak calej kanaperki long long suma = 0, aktual = 0; if(MyNodeId()==0) { for(int i=0; i<n; i++) { aktual += GetTaste(i); if(aktual > 0) { aktual = 0; } else { suma = min(aktual, suma); } } cout << smacznosciowosc - suma << endl; } return 0; } |