#include <iostream> #include <algorithm> #include "maklib.h" #include "message.h" using namespace std; int main(){ if ( MyNodeId() != 0 ){ return 0; } long long answer = ElementAt(1), partical_sum = 0, min_partical_sum = 0; for ( int right = 1; right <= Size(); ++right ){ partical_sum += ElementAt(right); answer = max ( answer, partical_sum - min_partical_sum ); min_partical_sum = min ( min_partical_sum, partical_sum ); } cout << max ( answer, 0LL ) << 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 | #include <iostream> #include <algorithm> #include "maklib.h" #include "message.h" using namespace std; int main(){ if ( MyNodeId() != 0 ){ return 0; } long long answer = ElementAt(1), partical_sum = 0, min_partical_sum = 0; for ( int right = 1; right <= Size(); ++right ){ partical_sum += ElementAt(right); answer = max ( answer, partical_sum - min_partical_sum ); min_partical_sum = min ( min_partical_sum, partical_sum ); } cout << max ( answer, 0LL ) << endl; return 0; } |