結果
| 問題 |
No.884 Eat and Add
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2019-09-13 21:49:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 1,000 ms |
| コード長 | 704 bytes |
| コンパイル時間 | 635 ms |
| コンパイル使用メモリ | 73,440 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-04 04:08:40 |
| 合計ジャッジ時間 | 1,172 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string s;
cin >> s;
int n = s.size();
int r = 0;
for (int i = n - 1; i >= 0; i--) {
if (s[i] == '1') {
r++;
if (i > 0 && s[i - 1] == '1') {
while (i >= 0 && s[i] == '1') i--;
if (i < 0) {
r++;
break;
}
s[i] = '1';
i++;
}
}
}
cout << r << endl;
return 0;
}
merom686