Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- long long int n, k, l = 0;
- cin >> n >> k;
- string s;
- cin >> s;
- if (k < 0)
- {
- l += abs(k);
- k = 0;
- }
- for (int i=0; i<n; i++)
- {
- if (k < 0)
- {
- k++;
- l++;
- }
- if (s[i] == 'C')
- k--;
- else if (s[i] == 'A')
- k++;
- }
- cout << l << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement