Josif_tepe

Untitled

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