AquaBlitz11

TASK_051 - AquaBlitz11's Solution

Jan 7th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int N = 101;
  6.  
  7. int arr[N];
  8.  
  9. int main()
  10. {
  11.     int n;
  12.     scanf("%d", &n);
  13.     for (int i = 1; i <= n; ++i)
  14.         scanf("%d", &arr[i]);
  15.     sort(arr+1, arr+n+1);
  16.  
  17.     int sum = 0, mxi = 0, mxc = 0, cnt = 0;
  18.     for (int i = 1; i <= n; ++i) {
  19.         if (arr[i] != arr[i-1])
  20.             cnt = 0;
  21.         ++cnt;
  22.         if (cnt >= mxc) {
  23.             mxc = cnt;
  24.             mxi = arr[i];
  25.         }
  26.         sum += arr[i];
  27.     }
  28.     double med = n%2 == 0 ? ((arr[n/2]+arr[n/2+1])/2.0) : arr[n/2+1];
  29.     printf("%.1f\n%.1f\n%.1f", sum*1.0/n, med, mxi*1.0);
  30.    
  31.     return 0;
  32. }
Add Comment
Please, Sign In to add comment