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