#include "message.h"
#include "maklib.h"
#include <iostream>
using namespace std;
int main() {
if (MyNodeId() == 0)
{
long long N = Size();
long long wynik = 0, temp = 0, liczba;
for (int i = 1; i <= N; ++i) {
liczba = ElementAt(i);
if (temp >= 0) {
temp = temp + liczba;
if (temp > wynik) wynik = temp;
}
else
temp = liczba;
}
cout << wynik << 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 "message.h" #include "maklib.h" #include <iostream> using namespace std; int main() { if (MyNodeId() == 0) { long long N = Size(); long long wynik = 0, temp = 0, liczba; for (int i = 1; i <= N; ++i) { liczba = ElementAt(i); if (temp >= 0) { temp = temp + liczba; if (temp > wynik) wynik = temp; } else temp = liczba; } cout << wynik << endl; } return 0; } |
English