Advertisement
SergeyNasekin

example

Jul 4th, 2022
995
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <vector>
  2. #include <string>
  3. #include <algorithm>
  4. #include <map>
  5.  
  6. using namespace std;
  7.  
  8. int CountAndAddNewDogs(const vector<string>& new_dogs,
  9.                        const map<string, int>& max_amount, map<string, int>& shelter) {
  10.  
  11.     return count_if(
  12.             new_dogs.begin(), new_dogs.end(),
  13.             [&max_amount, &shelter](const string& dog) {
  14.                 if(!shelter.count(dog)){
  15.                     shelter[dog] = 1;
  16.                     return true;
  17.                 }
  18.                 if(shelter.at(dog) < max_amount.at(dog)){
  19.                     ++shelter[dog];
  20.                     return true;
  21.                 }
  22.                 return false;
  23.             }
  24.     );
  25. }
  26.  
  27. int main() {
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement