結果

問題 No.3015 右に寄せろ!
ユーザー Hebiue
提出日時 2025-02-01 19:05:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 1,141 bytes
コンパイル時間 4,689 ms
コンパイル使用メモリ 221,668 KB
実行使用メモリ 8,444 KB
最終ジャッジ日時 2025-02-01 19:06:04
合計ジャッジ時間 6,874 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
#define bigmod 1000000007
#define P pair<ll,ll>
#define T tuple<ll,ll,ll>
#define nall(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()//逆順ソート
#define inf 2000000000000000000LL
#define mint modint998244353
#define mkp make_pair
#define mkt make_tuple
template<class X> using priority_minq = priority_queue<X, vector<X>, greater<X>>;//小さい順
ll min(ll a1,ll b1){if(a1>b1)return b1;else return a1;}
ll max(ll a1,ll b1){if(a1>b1)return a1;else return b1;}
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

//cout << fixed << setprecision(10); double型出力するときに使うやつ

string st;

int main(){
    ll ans = 0; ll cnt = 0;
    cin >> st;
    reverse(nall(st));
    rep(i,st.size()-1){
        if(st[i] == '0')cnt++;
        if(st[i] == '1' && st[i+1] == '1'){
            ans += cnt;
            st[i+1] = '0';
            cnt--;
        }
    }
    cout << ans << endl;
}
0