結果
| 問題 |
No.884 Eat and Add
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-13 22:16:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 1,000 ms |
| コード長 | 494 bytes |
| コンパイル時間 | 522 ms |
| コンパイル使用メモリ | 67,304 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 09:52:43 |
| 合計ジャッジ時間 | 1,140 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
int main() {
std::string N;
std::cin >> N;
int n=(int)N.length();
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;
}