Advertisement
Josif_tepe

Untitled

Dec 3rd, 2021
152
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.  
  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.     for (int i = 0; i < n; i++)
  15.     {
  16.         niza[i]++;
  17.     }
  18.     int zbir = 0;
  19.     for (int i = 0; i < n; i++)
  20.     {
  21.         zbir += niza[i];
  22.         if (zbir >= n)
  23.         {
  24.             cout << i+1 << endl;
  25.             return 0;
  26.         }
  27.     }
  28.  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement