Advertisement
Josif_tepe

Untitled

Feb 12th, 2021
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include<stack>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin >> n;
  9.     int niza[n];
  10.     for(int i = 0; i < n; i++) {
  11.         cin >> niza[i];
  12.     }
  13.     int broj_na_edinici = 0;
  14.     int rez = 0;
  15.     for(int i = 0; i < n; i++) {
  16.         if(niza[i] == 1) {
  17.             broj_na_edinici++;
  18.         }
  19.         else {
  20.             rez += broj_na_edinici;
  21.         }
  22.     }
  23.     cout << rez << endl;
  24.     return 0;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement