Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- long long n;
- cin>>n;
- long long niza[n];
- for(int i=1;i<=n;i++)
- {
- cin>>niza[i];
- }
- niza[0]=0;
- niza[n+1]=0;
- long long dolzina;
- long long interval=0;
- for( long long i=0;i<=n;i++)
- {
- if(niza[i]==0)
- {
- long long j=i+1;
- while(niza[j]!=0)
- {
- j++;
- }
- dolzina=(j-i-1);
- interval+=(dolzina*(dolzina+1))/2;
- i=j-1;
- }
- }
- cout<<n*(n+1)/2 - interval;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement