#include #include #include #include using namespace std; void max_players(vector &f, const int limit) { const int n = f.size(); sort(f.begin(), f.end()); int max_k = 0; int min_d = numeric_limits::max(); int l = 0; for (int r = 1; r < n; r++) { while ((r - l + 1) * (f[r] - f[l]) > limit) { l++; } int k = r - l + 1; int d = k * (f[r] - f[l]); if (max_k < k || (max_k == k && min_d > d)) { max_k = k; min_d = d; } } cout << max_k << " " << min_d << endl; } int main(void) { int n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int limit; cin >> limit; max_players(a, limit); return 0; }