You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
352 B
C++

#include <cstdio>
#include <set>
#include <vector>
using namespace std;
const int N = 2e5 + 20;
int a[N];
int main()
{
int n,ans=0;
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d", a + i);
for (int i = 1; i <= n; i++)
if (a[i - 1] == 1 && a[i] == 0 && a[i + 1] == 1)a[i + 1] = 0, ans++;
printf("%d", ans);
return 0;
}