結果
問題 |
No.3114 0→1
|
ユーザー |
|
提出日時 | 2025-04-20 13:21:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 581 bytes |
コンパイル時間 | 758 ms |
コンパイル使用メモリ | 67,028 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-04-20 13:21:17 |
合計ジャッジ時間 | 1,798 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | WA * 30 |
ソースコード
#include <iostream> #include <string> using namespace std; int minOperationsToGoodString(const string& S) { int balance = 0; int flips = 0; for (char ch : S) { if (ch == '1') { balance++; } else { balance--; } // If balance goes negative, flip a 0 to a 1 if (balance < 0) { flips++; balance += 2; // simulate flipping a 0 to a 1 } } return flips; } int main() { string S; cin >> S; cout << minOperationsToGoodString(S) << endl; return 0; }