35657

Untitled

Oct 5th, 2024
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <fstream>
  6.  
  7. const int FIELD_SIZE = 16;
  8.  
  9. int main() {
  10.  
  11.     std::ifstream fin("input.txt");
  12.  
  13.     int count, result = 0;
  14.  
  15.     fin >> count;
  16.  
  17.     count *= 2;
  18.  
  19.     char ch;
  20.  
  21.     std::vector<int> vec(9);
  22.  
  23.     for (int i = 0; i < FIELD_SIZE; i++) {
  24.         fin >> ch;
  25.         if (ch != '.') {
  26.             vec[ch - '1']++;
  27.         }
  28.     }
  29.  
  30.     for (int i = 0; i < 9; i++) {
  31.         if (vec[i] > 0 && vec[i] <= count) {
  32.             result++;
  33.         }
  34.     }
  35.     std::cout << result;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment