Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <cmath>
- #include <vector>
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int n;
- cin >> n;
- vector<long long> a(n);
- for (int i = 0; i < n; ++i) {
- cin >> a[i];
- }
- sort(a.begin(), a.end());
- long long m = a.back();
- long long l = 0;
- long long h = 0;
- for (int i = 0; i < n; ++i) {
- l += abs(a[i] - m);
- }
- int ans = 0;
- while (h < l) {
- a.pop_back();
- long long new_m = a.back();
- long long diff = m - new_m;
- l -= diff * a.size();
- h += m;
- m = new_m;
- ans++;
- }
- cout << ans;
- return 0;
- }
- c++ vector
- c++ compiler
- c++ string
- c++ map
- c++ tutorial
- c++ array
- c++ programming
- c++ getline
- c++ set
- c++ assert
- c++ absolute value
- c++ auto
- c++ array length
- c++ abstract class
- c++ atoi
- c++ abs
- c++ array initialization
- c++ algorithm
- a c++ class is similar to a(n)
- a c++ program
- a c++ stream is
- a c++ code line ends with
- a c++ primer
- a c++ program for binary search
- a c++ program with class
- a c++ project
- a c++ program to reverse a number
- a c++ program example
- c++ basics
- c++ break
- c++ binary search
- c++ bitset
- c++ boost
- c++ book
- c++ boolean
- c++ bitwise operators
- c++ bubble sort
- b c++ backspace
- b c++ boolean
- c++ 2 dimensional array
- c++ 2 dimensional vector
- c++ 2 decimal places
- c++ 2^n
- c++ 2 dimensional array initialization
- c++ 2's complement
- c++ 2 to the power of n
- c++ 2 dimensional array pointer
- c++ 9 redistributable
- c++ 9 for python
- c++ 9 download
- c++ 9 string to int
- netbeans 9 c++
- cloud9 c++
- 10^9 c++
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement