I was really Stuck in this Problem…
The Question is this:->CodeChef: Practical coding for everyone And my solution was this:->1nPIZe - Online C++0x Compiler & Debugging Tool - Ideone.com But if I change the while loop of this code to this-> >
ll count = 0, i = n;
while (z > 0 && !s.empty()) {
++count; --i;
auto it = --s.end();
z = z - it->first;
ll y = it->first;
s.erase(it);
y = y / 2;
if(y) {
s.insert(make_pair(y, i));
}
}
if(z > 0) {
std :: cout << “Evacuate” << std :: endl;
continue;
}
cout << count << endl;
IT Gives AC… I want to know what is the problem in my code… The second was written on the Editorial… Also using hashing it would be easy but I want to learn sets and also CC said to apply either sets or Priority Queue so I used this… THANKS!!!