// Grzegorz Bukowiec // Potyczki Algorytmiczne 2018 // Runda probna rozproszona - Kanapka #include <iostream> #include <algorithm> #include "message.h" #include "kanapka.h" using namespace std; int main() { long long n = GetN(); long long id = MyNodeId(); if (id == 0) { long long minHere = 0; long long minOverall = 0; long long sum = 0; for (long long i = 0; i < n; ++i) { sum += GetTaste(i); if (minHere > 0) { minHere = 0; } minHere += GetTaste(i); if (minOverall > minHere) { minOverall = minHere; } } cout << sum - minOverall << 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 | // Grzegorz Bukowiec // Potyczki Algorytmiczne 2018 // Runda probna rozproszona - Kanapka #include <iostream> #include <algorithm> #include "message.h" #include "kanapka.h" using namespace std; int main() { long long n = GetN(); long long id = MyNodeId(); if (id == 0) { long long minHere = 0; long long minOverall = 0; long long sum = 0; for (long long i = 0; i < n; ++i) { sum += GetTaste(i); if (minHere > 0) { minHere = 0; } minHere += GetTaste(i); if (minOverall > minHere) { minOverall = minHere; } } cout << sum - minOverall << endl; } return 0; } |