Official

B - Quizzes Editorial by tatyam


for 文などでループを回して、問題文の通りに点数を計算すれば AC が得られます。

回答例 (C++)

#include <iostream>
using namespace std;

int main(){
    int n, x;
    string s;
    cin >> n >> x >> s;
    for(char c : s){
        if(c == 'o') x++;
        else if(x) x--;
    }
    cout << x << endl;
}

回答例 (Python)

N, X = map(int, input().split())
S = input()
for s in S:
    if s == 'o':
        X += 1
    elif X:
        X -= 1
print(X)

posted:
last update: