結果
| 問題 |
No.884 Eat and Add
|
| コンテスト | |
| ユーザー |
Imperi_Night
|
| 提出日時 | 2019-09-13 22:26:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 1,028 bytes |
| コンパイル時間 | 916 ms |
| コンパイル使用メモリ | 96,624 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 09:59:26 |
| 合計ジャッジ時間 | 1,308 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using ll = long long;
using P = std::pair<ll, ll>;
#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug "<< i << std::endl
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;
int main() {
std::cin.tie(0);
std::ios::sync_with_stdio(false);
//問題文中の添え字が0-indexか1-indexか確認!
std::string s;
std::cin>>s;
ll n=s.size(),ans=0,cnt=0;
for(ll i=n-1;i>=0;i--){
if(s[i]=='0'){
if(cnt>=2){
ans++;
cnt=1;
}else{
ans+=cnt;
cnt=0;
}
}else{
cnt++;
}
}
if(cnt>=2)ans+=2;
else ans+=cnt;
std::cout<<ans;
return 0;
}
Imperi_Night