結果
| 問題 |
No.884 Eat and Add
|
| コンテスト | |
| ユーザー |
moririn2528_c
|
| 提出日時 | 2019-09-13 22:06:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 1,000 ms |
| コード長 | 981 bytes |
| コンパイル時間 | 757 ms |
| コンパイル使用メモリ | 91,464 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 09:43:52 |
| 合計ジャッジ時間 | 1,320 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;
void array_show(int *array,int array_n,char middle=' '){
for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
string sa;
bool t[200005];
int main(){
int n,m;
int i,j,k;
int a,b,c;
int s=0;
cin>>sa;
n=sa.size();
for(i=n-1;i>=0;i--){
if(sa[i]=='1')t[n-i-1]=true;
}
for(i=0;i<n;i++){
if(!t[i])continue;
if(!t[i+1]){s++;continue;}
for(;t[i];i++);
if(t[i+1])t[i--]=true,s++;
else s+=2;
}
cout<<s<<endl;
}
moririn2528_c