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