Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- const int min(const int a, const int b);
- const int min(const int a, const int b) { return (b < a) ? b : a; }
- int main() {
- int n_friends, mood;
- char friends [200001];
- scanf("%d %d\n%200000s", &n_friends, &mood, friends);
- int min_mood = mood;
- for (int i = 0; i < n_friends - 1; i++) {
- if (friends[i] == 'A') { mood++; min_mood = min(min_mood, mood); }
- else if (friends[i] == 'C') { mood--; min_mood = min(min_mood, mood); }
- }
- printf("%d", -min(0, min_mood));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement