#include #include #include #include int main() { using namespace std; int n, k; cin >> n; cin >> k; cout << n << k; vector arr; arr.resize(n); vector arr_ordered; for (int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr.begin(), arr.end()); double avg = 0; double avg_tail = 0; for (int i = 0; i < k-1; i++) { avg += arr[i]; } for (int i = k-1; i < n; i++) { avg_tail += arr[i]; } avg_tail = avg_tail / (n - k + 1); avg += avg_tail; cout << "avg" << avg << endl; return avg; }