結果

問題 No.3015 右に寄せろ!
ユーザー t98slider
提出日時 2025-01-25 13:05:38
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 447 bytes
コンパイル時間 2,095 ms
コンパイル使用メモリ 192,696 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-25 22:32:35
合計ジャッジ時間 2,896 ms
ジャッジサーバーID
(参考情報)
judge7 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int one = 0;
    ll ans = 0;
    for(int i = 0; i < s.size(); ){
        int p = i;
        while(i < s.size() && s[i] == s[p]) i++;
        if(s[p] == '1'){
            one += (i - p) / 2;
        }else{
            ans += one * (ll)(i - p);
        }
    }
    cout << ans << '\n';
}
0