X-Git-Url: https://ruin.nu/git/?p=icfp05.git;a=blobdiff_plain;f=robber%2Frobber.cpp;h=f586f6ae3267a4e95664d54c4c8ec2e9c36d8d38;hp=4bc04000f79ff21efba4c7ba2d6e62eb1818fad1;hb=bce3d3b3c8b9f91f27000149fbd04f3a7f14800e;hpb=ea32d9ec2a34aa06cce2495c4efcb0864911be43 diff --git a/robber/robber.cpp b/robber/robber.cpp index 4bc0400..f586f6a 100644 --- a/robber/robber.cpp +++ b/robber/robber.cpp @@ -1,6 +1,7 @@ #include "robber.h" #include #include +#include #include using namespace std; @@ -53,7 +54,7 @@ string Robber::turn(){ continue; } - vector banks; + priority_queue banks; for(hash_map::const_iterator bank = _banks.begin(); bank != _banks.end(); ++bank){ //cerr << "Handling bank at: " << bank->first << endl; @@ -63,13 +64,15 @@ string Robber::turn(){ continue; //list::iterator i = l.begin(); //++i; - banks.push_back(bank->second/(pow(l.size(),4.0))); + banks.push(bank->second/(pow(l.size(),4.0))); } } - sort(banks.begin(),banks.end(),greater()); + //sort(banks.begin(),banks.end(),greater()); - for (unsigned int i = 0; i < 2 && i < banks.size();++i) - goodness += banks[i]; + for (unsigned int i = 0; i < 2 && banks.size() > 0;++i){ + goodness += banks.top(); + banks.pop(); + } cerr << "Goodness before cop: " << goodness << endl; if (closestCop > 2){