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