結果
問題 | No.3015 右に寄せろ! |
ユーザー |
![]() |
提出日時 | 2025-01-25 13:37:45 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 453 bytes |
コンパイル時間 | 3,440 ms |
コンパイル使用メモリ | 275,088 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-01-25 22:52:51 |
合計ジャッジ時間 | 5,043 ms |
ジャッジサーバーID (参考情報) |
judge9 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 WA * 30 |
ソースコード
#include <bits/stdc++.h>int main() {std::ios::sync_with_stdio(false);std::cin.tie(nullptr);std::string S; std::cin >> S;std::reverse(S.begin(), S.end());int ans = 0;int idx = -1;for (int i = 0; i + 2 < (int)S.size(); i++) {if (S.substr(i, 3) == "011") {ans += i - idx;idx += 2;S[i + 1] = '0';S[i + 2] = '0';} else if (S[i] == '1') {idx = i + 1;}}std::cout << ans << '\n';}