fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <deque>
  7. #include <map>
  8. using namespace std;
  9.  
  10. #define fastIo ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  11.  
  12. struct Info {
  13. int clas;
  14. string name;
  15. };
  16.  
  17. double RR(double n, int size) {
  18. n /= size;
  19. n = round(n);
  20. return n;
  21. }
  22.  
  23. int main() {
  24. fastIo;
  25. int n;
  26. cin >> n;
  27. int input;
  28. double sum = 0;
  29. int minI = 5000001, maxI = -5000001;
  30. vector<int>v;
  31. vector<int>bin;
  32. map<int, int>m;
  33. for (int i = 0; i < n; i++)
  34. {
  35. cin >> input;
  36. v.push_back(input);
  37. sum += input;
  38. if (input < minI)
  39. minI = input;
  40. if (input > maxI)
  41. maxI = input;
  42. if (m.count(input) == 0) {
  43. bin.push_back(input);
  44. m.insert({ input, 1 });
  45. }
  46. else
  47. m[input]++;
  48. }
  49. int binMax = 0;
  50. sort(v.begin(), v.end());
  51. for (int i = 0; i < bin.size(); i++)
  52. {
  53. if (m[binMax] < m[bin[i]])
  54. binMax = bin[i];
  55. }
  56. cout.precision(0);
  57. cout << fixed;
  58. if (RR(sum, n) == -0) {
  59. cout << RR(sum, n) * -1 << "\n";
  60. }
  61. else
  62. cout << RR(sum, n) << "\n";
  63. cout << v[n / 2] << "\n";
  64. cout << binMax << "\n";
  65. cout << maxI - minI << "\n";
  66.  
  67. }
  68.  
  69.  
Success #stdin #stdout 0.01s 5280KB
stdin
5
0
0
0
0
0
stdout
-0
0
0
0