結果
問題 |
No.884 Eat and Add
|
ユーザー |
![]() |
提出日時 | 2019-08-22 21:03:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 1,000 ms |
コード長 | 454 bytes |
コンパイル時間 | 1,606 ms |
コンパイル使用メモリ | 167,196 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-12 22:07:58 |
合計ジャッジ時間 | 2,398 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h> int main() { std::string s; std::cin >> s; std::reverse(s.begin(), s.end()); int n = s.size(); int res = 0; for (int i = 0; i < n; i++) { if (s[i] == '0') continue; int j = i; int cost = 1; while (j > 1) { if (s[j - 1] == '1' && s[j - 2] == '1') { cost = 0; break; } if (s[j - 1] == '1' && s[j - 2] == '0') j -= 2; else break; } res += cost; } std::cout << res << std::endl; return 0; }