#include "maklib.h" #include "message.h" #include <stdio.h> #include <stdlib.h> #include <iostream> using namespace std; int main() { if (!MyNodeId()) { const int n = Size(); long long int sum = 0; for (int i = 1; i <= n; i++) { sum = ((sum > 0) ? sum : 0) + (long long int) ElementAt(i); } sum = ((sum > 0) ? sum : 0); cout << sum << 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 | #include "maklib.h" #include "message.h" #include <stdio.h> #include <stdlib.h> #include <iostream> using namespace std; int main() { if (!MyNodeId()) { const int n = Size(); long long int sum = 0; for (int i = 1; i <= n; i++) { sum = ((sum > 0) ? sum : 0) + (long long int) ElementAt(i); } sum = ((sum > 0) ? sum : 0); cout << sum << endl; } return 0; } |