Source Code
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <deque>
#include <set>

using namespace std;


int main()
{
    //speedup;
    string s;
    int ans=0;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        if(s[i]=='1')
        {
            ans++;
        }
        else
        {
            if(0<i&&i<n-1)
            {
                if(s[i-1]=='1'&&s[i+1]=='1')
                {
                    ans++;
                }
            }
        }
    }
    cout<<ans;

    return 0;
}
Copy
Japanese holidays IssamAbdoh
GNU G++17
3 ms
228 KB
Wrong Answer