#include #include using namespace std; int min_operations_to_good_string(int N, const string& S) { int zero_count = 0; // 現在までの0の数 int one_count = 0; // 現在までの1の数 int operations = 0; // 操作回数 for (char c : S) { if (c == '0') { zero_count++; } else { one_count++; } // `0` が `1` より多い場合、修正が必要 if (zero_count > one_count) { operations++; zero_count--; // 1つの `0` を `1` に変換 } } return operations; } int main() { int N; string S; // 入力 cin >> N; cin >> S; // 結果の出力 cout << min_operations_to_good_string(N, S) << endl; return 0; }