結果

問題 No.884 Eat and Add
ユーザー llllltwwwwwllllltwwwww
提出日時 2019-09-13 22:56:37
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 681 bytes
コンパイル時間 2,112 ms
コンパイル使用メモリ 66,452 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-17 15:04:19
合計ジャッジ時間 2,213 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 7 ms
4,384 KB
testcase_04 AC 6 ms
4,384 KB
testcase_05 AC 6 ms
4,380 KB
testcase_06 AC 6 ms
4,380 KB
testcase_07 AC 6 ms
4,380 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<cmath>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;


int main(){
  ll ans=0;
  int count=0;
  string s;
  cin>>s;
  for(int i=0;i<3;i++)s.push_back('0');
  
  for(int i=0;i<(int)s.size();i++){
    
    if(s[i]=='1') count++;
    else{
      if(count==1) ans++;
      
      else if(count==0) ;
      
      else if(s[i+1]=='1'){
        ans++;
        count++;
        continue;
      }else ans+=2;
      count=0;
    }
    //cout<<i<<" "<<ans<<endl;
  }
  cout<<ans<<endl;
}
0