結果

問題 No.3015 右に寄せろ!
ユーザー cafe net
提出日時 2025-01-25 15:31:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 357 bytes
コンパイル時間 791 ms
コンパイル使用メモリ 65,580 KB
実行使用メモリ 8,312 KB
最終ジャッジ日時 2025-01-25 23:46:48
合計ジャッジ時間 2,565 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	string S;
	cin>>S;
	int N=S.size();
	reverse(S.begin(),S.end());
	int cnt=0;
	long ans=0;
	rep(i,N-1){
		if(S.substr(i,2)=="11"){
			ans+=i-cnt;
			cnt+=2;
			i++;
            continue;
		}
		if(S[i]=='1'){
			cnt++;
		}
	}
	cout<<ans<<endl;
}
0