結果
| 問題 |
No.884 Eat and Add
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-13 22:15:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 1,000 ms |
| コード長 | 558 bytes |
| コンパイル時間 | 570 ms |
| コンパイル使用メモリ | 71,040 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 09:51:38 |
| 合計ジャッジ時間 | 1,149 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <deque>
const int NMAX=212345;
int main() {
std::string N;
std::cin >> N;
int n=(int)N.length();
std::deque<int> dq;
int cnt=0, pos=n-1;
int ans=0;
while (pos>=0) {
if (N[pos]=='0') {
--pos;
continue;
}
while (pos>=0&&N[pos]=='1') {
--pos;
++cnt;
}
if (cnt>0) {
++ans;
if (cnt>1) {
if (pos>=0)
N[pos]='1';
else
++ans;
}
cnt=0;
}
}
std::cout << ans << std::endl;
}