Advertisement
Josif_tepe

Untitled

May 24th, 2024
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin >> n;
  9.    string s;
  10.    cin >> s;
  11.  
  12.    int nepogodeni = 0;
  13.  
  14.    for(int i = 0; i < s.size(); i++) {
  15.     if(s[i] == 'C') {
  16.         int A = 0;
  17.         int B = 0;
  18.         for(int j = i + 1; j < s.size(); j++) {
  19.             if(s[j] == 'C') {
  20.                 if(A <= B) {
  21.                     nepogodeni++;
  22.                 }
  23.                 break;
  24.             }
  25.             if(s[j] == 'A') {
  26.                 A++;
  27.             }
  28.             if(s[j] == 'B') {
  29.                 B++;
  30.             }
  31.         }
  32.        
  33.     }
  34.    }
  35.    if(nepogodeni == 0) {
  36.     cout << "POGODENA" << endl;
  37.    }
  38.    else {
  39.     cout << nepogodeni << endl;
  40.    }
  41.    
  42.     return 0;
  43. }
  44. // CABABBCBAABBC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement