Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- string s;
- cin >> s;
- int nepogodeni = 0;
- for(int i = 0; i < s.size(); i++) {
- if(s[i] == 'C') {
- int A = 0;
- int B = 0;
- for(int j = i + 1; j < s.size(); j++) {
- if(s[j] == 'C') {
- if(A <= B) {
- nepogodeni++;
- }
- break;
- }
- if(s[j] == 'A') {
- A++;
- }
- if(s[j] == 'B') {
- B++;
- }
- }
- }
- }
- if(nepogodeni == 0) {
- cout << "POGODENA" << endl;
- }
- else {
- cout << nepogodeni << endl;
- }
- return 0;
- }
- // CABABBCBAABBC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement