#include <map> #include <string> #include <vector> #include <algorithm> #include <iostream> #include <cmath> #include <iomanip> #include <set> #include <unordered_set> #define M_PI 3.14159265358979323846 #define ull unsigned long long #define ll long long #define vi vector<int> #define vll vector<long long> #define vull vector<unsigned long long> #define ld long double #define pii pair<int,int> #define pll pair<long long, long long> #define vvi vector<vector<int>> using namespace std; #include "kanapka.h" #include "message.h" #include <cmath> ll previ[33000000]; int main() { ll n = GetN(); long long all = 0; long long best = -1; for (int i = 0; i < n; ++i) { all += GetTaste(i); previ[i] = all; } best = all; for (int i = 0; i < n; ++i) { for (int j = i+1; j < n; ++j) { best = max(all - (previ[j] - previ[i]), best); } } if (MyNodeId() == 0) { cout << max(0ll, best); } 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #include <map> #include <string> #include <vector> #include <algorithm> #include <iostream> #include <cmath> #include <iomanip> #include <set> #include <unordered_set> #define M_PI 3.14159265358979323846 #define ull unsigned long long #define ll long long #define vi vector<int> #define vll vector<long long> #define vull vector<unsigned long long> #define ld long double #define pii pair<int,int> #define pll pair<long long, long long> #define vvi vector<vector<int>> using namespace std; #include "kanapka.h" #include "message.h" #include <cmath> ll previ[33000000]; int main() { ll n = GetN(); long long all = 0; long long best = -1; for (int i = 0; i < n; ++i) { all += GetTaste(i); previ[i] = all; } best = all; for (int i = 0; i < n; ++i) { for (int j = i+1; j < n; ++j) { best = max(all - (previ[j] - previ[i]), best); } } if (MyNodeId() == 0) { cout << max(0ll, best); } return 0; } |