Advertisement
Josif_tepe

Untitled

Oct 22nd, 2021
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2.  
  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.     {
  12.         cin >> niza[i];
  13.  
  14.     }
  15.     int teleportacii = 0;
  16.     int broj_na_edinici = 0;
  17.     for (int i = 0; i < n; i++)
  18.     {
  19.         if (niza[i] == 1)
  20.         {
  21.             broj_na_edinici++;
  22.         }
  23.         else if (niza[i] == 2)
  24.         {
  25.             teleportacii += broj_na_edinici;
  26.         }
  27.     }
  28.     cout << teleportacii << endl;
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement