84772024-01-17 12:45:48anonLegtöbb gyümölcs (40 pont)cpp17Accepted 40/403ms3592 KiB
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long long ll;
int main() {
    FastIO;
    ll i, ac, pc, N;
    string s;
    cin >> N >> s;
    pc = count(all(s), 'K');
    for(i = 0; i < N && ac < pc; i++) {
        ac += s[i] == 'A';
        pc -= s[i] == 'K';
    }
    cout << ac * 2 << '\n';
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1972 KiB
2Accepted0/03ms2528 KiB
3Accepted2/23ms2328 KiB
4Accepted2/23ms2544 KiB
5Accepted2/23ms2568 KiB
6Accepted2/23ms2740 KiB
7Accepted2/23ms2872 KiB
8Accepted3/33ms2952 KiB
9Accepted3/33ms2980 KiB
10Accepted3/33ms3080 KiB
11Accepted3/33ms3296 KiB
12Accepted3/33ms3432 KiB
13Accepted3/33ms3444 KiB
14Accepted3/33ms3592 KiB
15Accepted3/33ms3540 KiB
16Accepted3/33ms3540 KiB
17Accepted3/33ms3560 KiB