velimir

Podaroci

Mar 24th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int y=0, i, n, tempZbir=0, zbir;
  8.     cin >> n;
  9.     int niza[n];
  10.     for(i=0; i<n; i++)
  11.     {
  12.         cin >> niza[i];
  13.         tempZbir+=niza[i];
  14.     }
  15.     if(tempZbir%n!=0){cout << "GRESHKA"; return 0;}
  16.     zbir = tempZbir/n;
  17.     for(i=0; i<n; i++)
  18.         if(niza[i]<zbir) y+=zbir-niza[i];
  19.     cout << y;
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment