#include<cstdio> #include<algorithm> #include "maklib.h" #include "message.h" using namespace std; const int NODE = MyNodeId(); const int SIZE = Size(); const int NODES = NumberOfNodes(); const int CHUNK = 1 + SIZE/NODES; const int ITERATIONS = 20; void single() { if (MyNodeId() == 0) { long long smax = 0LL, s = 0LL; for(int i = 1; i <= SIZE; i++) { const long long a = ElementAt(i); s = max(s + a, max(a, 0LL)); smax = max(smax, s); } printf("%lld\n", smax); } } int main() { single(); }
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 | #include<cstdio> #include<algorithm> #include "maklib.h" #include "message.h" using namespace std; const int NODE = MyNodeId(); const int SIZE = Size(); const int NODES = NumberOfNodes(); const int CHUNK = 1 + SIZE/NODES; const int ITERATIONS = 20; void single() { if (MyNodeId() == 0) { long long smax = 0LL, s = 0LL; for(int i = 1; i <= SIZE; i++) { const long long a = ElementAt(i); s = max(s + a, max(a, 0LL)); smax = max(smax, s); } printf("%lld\n", smax); } } int main() { single(); } |