#include <stdio.h> #include <stdlib.h> #include "maklib.h" #include "message.h" int main() { long long int max = 0; long long int current = 0; if (MyNodeId() == 0) { for(int i=1; i<=Size(); i++) { current += ElementAt(i); if(current < 0) current = 0; if(current > max) max = current; } printf("%lld", max); } 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 | #include <stdio.h> #include <stdlib.h> #include "maklib.h" #include "message.h" int main() { long long int max = 0; long long int current = 0; if (MyNodeId() == 0) { for(int i=1; i<=Size(); i++) { current += ElementAt(i); if(current < 0) current = 0; if(current > max) max = current; } printf("%lld", max); } return 0; } |