SHARE
TWEET

ыыыы

a guest Oct 15th, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <algorithm>
  5. #include <cmath>
  6.  
  7.  
  8. int main() {
  9. #ifdef LOCAL
  10.     freopen("input.txt", "r", stdin);
  11.     freopen("output.txt", "w", stdout);
  12. #endif
  13.     int n, k;
  14.     std::cin >> n >> k;
  15.     int min = 0, now = 0;
  16.     std::string s;
  17.     std::cin >> s;
  18.     if (s.back() == 'C')
  19.         s.pop_back();
  20.     for (auto a : s) {
  21.         if (a == 'A') {
  22.             now++;
  23.         } else if (a == 'C') {
  24.             now--;
  25.             min = std::min(now, min);
  26.         }
  27.     }
  28.     if (min + k >= 0)
  29.         std::cout << 0;
  30.     else
  31.         std::cout << -(min + k);
  32.     return 0;
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top