#include #include #include #include #include // TLE: does not sort the list and instead recomputes for each interesting framerate. int main(){ int n, m; std::cin >> n >> m; std::vector xs; int x; for (int i = 0; i < n; i++) { std::cin >> x; xs.push_back(x); } long long t = 0; // first do f = M for (int i = 0; i < n; i++) { x = xs[i]; t += ceil((double)(m * x) / 1000.0f); } double optt = (double)t / m; // Now all interesting points for (int i = 0; i < n; i++) { x = xs[i]; int maxv = (m * x) / 1000; for (int k = 1; k <= maxv; k++) { //DO NOT enumerate in sorted order -> TLE double t = 0; for (int j = 0; j < n; j++) { int y = xs[j]; t += ceil(((double)k * (double)y) / (double)x); } double curt = (t * x) / (1000.0f * k); if (curt < optt) optt = curt; } } std::cout << std::setprecision(10) << optt << std::endl; }