// Saarland University: <(OvO)> #include #define sz(a) ((int)(a).size()) #define divceil(a, b) ((a) + (b) - 1) / (b) using namespace std; #ifdef ONPC string to_string(const char* s) { return s; } template string to_string(const T& cont) { string ans = ""; for (bool fst = true; const auto& val: cont) { if (!fst) { ans += ", "; } ans += to_string(val); fst = false; } return ans + "}"; } void debug_print_collection() { cerr << endl; } template void debug_print_collection(First val, Args... args) { cerr << " " << to_string(val); debug_print_collection(args...); } #define debug(...) { cerr << "@@@ [" << #__VA_ARGS__ << "] ="; debug_print_collection(__VA_ARGS__);} #else #define debug(...) ; #define NDEBUG #endif mt19937 rnd(123); typedef long long ll; typedef long double ld; int solve() { int n; if (!(cin >> n)) { return 1; } ld tm = clock() * 1.0 / CLOCKS_PER_SEC; int k; cin >> k; vector h(n); for (int i = 0; i < n; i++) { cin >> h[i]; } int tr = 500; int le = max(1, k / tr); vector> v; for (int a = 1; a < k; a += le) { ll sum = 0; for (int i = 0; i < n; i++) { sum += divceil(h[i], a); } v.push_back({(ld)sum / (ld)(k - a), a}); } sort(v.begin(), v.end()); ll up = 1e18, dw = 1, ao = 1; int T = le + 3; for (auto [_, aa] : v) { if (clock() * 1.0 / CLOCKS_PER_SEC - tm > 3.8) { break; } for (int a = max(aa - T, 1); a < max(aa + T, k); a++) { if (clock() * 1.0 / CLOCKS_PER_SEC - tm > 3.8) { break; } ll sum = 0; for (int i = 0; i < n; i++) { sum += divceil(h[i], a); } ll b = k - a; if ((__int128_t) up * b > (__int128_t)sum * dw) { up = sum; dw = b; ao = a; } } } cout << ao << ' ' << k - ao << '\n'; return 0; } int32_t main() { #ifdef ONPC assert(freopen("E.txt", "r", stdin)); #endif int TET = 1e9; // cin >> TET; for (int i = 1; i <= TET; i ++) { if (solve()) { break; } #ifdef ONPC cout << "__________________" << endl; #endif } #ifdef ONPC cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl; #endif } /* g++ -std=c++20 -Wall -Wextra -Wshadow -D_GLIBCXX_DEBUG -DONPC -O2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -o ex template.cpp && ./ex */