Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. long long int n, k, l = 0;
  9. cin >> n >> k;
  10. string s;
  11. cin >> s;
  12. if (k < 0)
  13. {
  14. l += abs(k);
  15. k = 0;
  16. }
  17. for (int i=0; i<n; i++)
  18. {
  19. if (k < 0)
  20. {
  21. k++;
  22. l++;
  23. }
  24. if (s[i] == 'C')
  25. k--;
  26. else if (s[i] == 'A')
  27. k++;
  28. }
  29. cout << l << endl;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement