Naxocist

ants

Apr 29th, 2023
748
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | Source Code | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. using ll = long long int;
  5.  
  6. int main() {
  7.     int n; scanf("%d", &n);
  8.  
  9.     ll res = 0, k = 0;
  10.     for(ll i=0; i<n; ++i) {
  11.         ll x; scanf("%lld", &x);
  12.         if(x == 0) res += i - k++;
  13.     }
  14.     printf("%lld", res);
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment