Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <string>
- #include <algorithm>
- #include <map>
- using namespace std;
- int CountAndAddNewDogs(const vector<string>& new_dogs,
- const map<string, int>& max_amount, map<string, int>& shelter) {
- return count_if(
- new_dogs.begin(), new_dogs.end(),
- [&max_amount, &shelter](const string& dog) {
- if(!shelter.count(dog)){
- shelter[dog] = 1;
- return true;
- }
- if(shelter.at(dog) < max_amount.at(dog)){
- ++shelter[dog];
- return true;
- }
- return false;
- }
- );
- }
- int main() {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement