結果

問題 No.3114 0→1
ユーザー AK_Mi
提出日時 2025-04-18 22:44:01
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 631 bytes
コンパイル時間 1,753 ms
コンパイル使用メモリ 191,828 KB
実行使用メモリ 16,512 KB
最終ジャッジ日時 2025-04-18 22:44:25
合計ジャッジ時間 8,164 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other TLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    int zero = 0;
    int one = 0;
    int count = 0;
    string s,ss;
    
    cin >> n >> s;
    ss = s;
    
    for(int i = 0; i < n; i++){
        if(s.at(i) == '1')continue;
        
        for(int t = i + 1; t < n; t++){
            if(s.at(t) == '1')one++;
            else zero++;
            
            if(zero > one){
                s.at(t) = '1';
                count++;
                zero--;
                one++;
            }
        }
        
        zero = 0;
        one = 0;
    }

    cout << count << endl;
    
    return 0;
}
0