結果
問題 | No.3015 右に寄せろ! |
ユーザー |
|
提出日時 | 2025-01-25 12:58:30 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 72 ms / 2,000 ms |
コード長 | 685 bytes |
コンパイル時間 | 5,373 ms |
コンパイル使用メモリ | 334,896 KB |
実行使用メモリ | 25,620 KB |
最終ジャッジ日時 | 2025-01-25 22:28:22 |
合計ジャッジ時間 | 7,112 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge10 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
#include<bits/stdc++.h>using namespace std;#include<atcoder/all>using namespace atcoder;using mint=atcoder::modint998244353;#pragma GCC optimize("O3")#pragma GCC optimize("unroll-loops")#define int long longsigned main(){string S;cin>>S;vector<pair<char,int>> st;int ans=0;for(auto&&e:S){if(e=='0'){if(st.size()&&st.back().first=='1'){ans+=st.back().second/2;int tmp=st.back().second;st.pop_back();st.push_back({'0',1});st.push_back({'1',tmp/2*2});}else{st.push_back({'0',1});}}else{if(st.size()&&st.back().first==e){st.back().second++;}else{st.push_back({e,1});}}}cout<<ans<<endl;}