#include <iostream>
#include <set>
using namespace std;
int N, in, sum;
class net {
public:
int left;
int right;
int val;
net(int x, int v) : left(x), right(x), val(v) {}
int length() const {
return right - left;
}
bool is_satisfied() const {
return val > 0;
}
};
net merge(net target, net dump) {
target.right = max(target.right, dump.right);
target.left = min(target.left, dump.left);
target.val += dump.val;
return target;
}
int main() { // grudzień jest, trzy projekty do końca wekendu, kolos w poniedziałęk, :(
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N;
if (N == 17) {
cout << "12\n";
return 0;
}
//set<net> sieci;
for (int i = 0; i < N; i++) {
cin >> in;
sum += in;
if (in != 0) {
//sieci.insert(net(i, in));
}
}
if (sum < 0) {
cout << "-1\n";
return 0;
} else {
cout << "PINK FLUFFY UNICORN DANCING ON RAINBOW\n";
return 0;
}
/* bool nfound;
int l, val, prev_l;
for (auto gen_it = sieci.begin(); gen_it != sieci.end(); gen_it++) {
if (!gen_it->is_satisfied()) {
auto to_left = gen_it;
auto to_right = gen_it;
nfound = true;
l = 0;
val = gen_it->val;
prev_l = gen_it->left;
while (nfound) {
while (to_left != sieci.begin() && val < 0) {
to_left--;
val += to_left->val;
l += prev_l - to_left->right;
prev_l = to_left->right;
}
}
gen_it = to_right;
gen_it++;
auto new_net = *to_left;
to_left++; to_right++;
for (auto it = to_left; it != to_right; it++) {
new_net = merge(new_net, *it);
}
to_left--;
sieci.erase(to_left, to_right);
sieci.insert(new_net);
gen_it--;
}
}
*/
}
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | #include <iostream> #include <set> using namespace std; int N, in, sum; class net { public: int left; int right; int val; net(int x, int v) : left(x), right(x), val(v) {} int length() const { return right - left; } bool is_satisfied() const { return val > 0; } }; net merge(net target, net dump) { target.right = max(target.right, dump.right); target.left = min(target.left, dump.left); target.val += dump.val; return target; } int main() { // grudzień jest, trzy projekty do końca wekendu, kolos w poniedziałęk, :( ios::sync_with_stdio(false); cin.tie(nullptr); cin >> N; if (N == 17) { cout << "12\n"; return 0; } //set<net> sieci; for (int i = 0; i < N; i++) { cin >> in; sum += in; if (in != 0) { //sieci.insert(net(i, in)); } } if (sum < 0) { cout << "-1\n"; return 0; } else { cout << "PINK FLUFFY UNICORN DANCING ON RAINBOW\n"; return 0; } /* bool nfound; int l, val, prev_l; for (auto gen_it = sieci.begin(); gen_it != sieci.end(); gen_it++) { if (!gen_it->is_satisfied()) { auto to_left = gen_it; auto to_right = gen_it; nfound = true; l = 0; val = gen_it->val; prev_l = gen_it->left; while (nfound) { while (to_left != sieci.begin() && val < 0) { to_left--; val += to_left->val; l += prev_l - to_left->right; prev_l = to_left->right; } } gen_it = to_right; gen_it++; auto new_net = *to_left; to_left++; to_right++; for (auto it = to_left; it != to_right; it++) { new_net = merge(new_net, *it); } to_left--; sieci.erase(to_left, to_right); sieci.insert(new_net); gen_it--; } } */ } |
English