Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- typedef unsigned long long int ull;
- typedef vector<int> vi;
- typedef vector<ll> vll;
- typedef vector<vi> vvi;
- typedef pair<int,int> pii;
- typedef vector< pii > vpii;
- typedef set<int> sti;
- #define pb push_back
- #define pob pop_back
- #define mp make_pair
- #define ff first
- #define ss second
- #define loop1(i,n) for(int i=1; i<=int(n); i++)
- #define loop(i,y) for(int i=0; i<int(y); i++)
- #define rloop(i,y) for(int i=int(y); i>0; i--)
- #define rloop1(i,y) for(int i=int(y)-1; i>=0; i--)
- #define read() freopen("input.txt", "r", stdin)
- #define write() freopen("output.txt", "w", stdout)
- #define cspf(i) printf("Case %d: \n", i)
- #define all(v) v.begin(),v.end()
- #define rall(v) v.rbegin(),v.rend()
- /// Constants
- #define eps 1e-9
- #define PI acos(-1.0) // 3.1415926535897932
- int main()
- {
- int n,k=0;
- cin>>n;
- int a[n+1],flg[n+1];
- memset(flg,0,sizeof(flg));
- loop(i,n)
- cin>>a[i];
- for(int i=1;i<n-1;i++){
- if(a[i]==0){
- if(a[i-1]==1 && a[i+1]==1){
- flg[k]=i;
- k++;
- }
- }
- }
- int j,y,mx=0;
- loop(i,k){
- if(flg[i]==0)
- continue;
- y=flg[i+1]-flg[i];
- if(y==2){
- mx++;
- flg[i]=0;
- flg[i+1]=0;
- }
- else{
- flg[i]=0;
- mx++;
- }
- }
- cout<<mx<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement