#include "robber.h"
#include <iostream>
#include <iterator>
+#include <queue>
#include <cmath>
using namespace std;
continue;
}
- vector<double> banks;
+ priority_queue<double> banks;
for(hash_map<string,int>::const_iterator bank = _banks.begin();
bank != _banks.end(); ++bank){
//cerr << "Handling bank at: " << bank->first << endl;
continue;
//list<string>::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<double>());
+ //sort(banks.begin(),banks.end(),greater<double>());
- 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){