結果
問題 | No.3015 右に寄せろ! |
ユーザー |
|
提出日時 | 2025-02-22 02:26:18 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 736 bytes |
コンパイル時間 | 3,706 ms |
コンパイル使用メモリ | 280,104 KB |
実行使用メモリ | 17,552 KB |
最終ジャッジ日時 | 2025-02-22 02:26:24 |
合計ジャッジ時間 | 4,918 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i=0; i<n; i++) // #include <all.hpp> #define int long long signed main() { string s; cin >> s; int n = s.length(); deque<pair<int, int>> st = {{0, 0}}; rep(i, n) { if(s[i] == '0') { if(st.back().first == 0) st.back().second++; else st.emplace_back(0, 1); } else { if(st.back().first == 1) st.back().second++; else st.emplace_back(1, 1); } } long long ans = 0; int one_cnt = 0; rep(i, st.size()) { if(st[i].first == 0) { ans += one_cnt / 2 * st[i].second; one_cnt -= one_cnt % 2; } else { one_cnt += st[i].second; } } cout << ans << endl; }