Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- int n,i;
- bool a[101] = {false};
- int first_para = -1;
- cin >> n;
- int last_para = n-1;
- cin >> a[0];
- for(i = 0; i < n; i++){
- cin >> a[i];
- if(a[i] && first_para<0)
- first_para = i;
- }
- while(!a[last_para]){
- last_para--;
- }
- cout << first_para << endl;
- cout << last_para << endl;
- int result = 0;
- int cnt = 0;
- for(i = first_para; i <= last_para; i++){
- if(!a[i] && cnt!=0){
- cnt++;
- }else{
- if(cnt>1){
- result-=cnt;
- cnt = 0;
- }
- }
- result++;
- }
- cout << result << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement