#include #define show(x) std::cerr << #x << " = " << (x) << std::endl template std::ostream& operator<<(std::ostream& os, const std::array& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::deque& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::multimap& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::multiset& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::map& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::pair& v) { return (os << "<" << v.first << "," << v.second << ">"); } template std::ostream& operator<<(std::ostream& os, const std::set& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::unordered_multimap& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::unordered_multiset& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::unordered_map& v) { os << "["; for (const auto& e : v) { os << "<" << e.first << ": " << e.second << ">,"; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::unordered_set& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } template std::ostream& operator<<(std::ostream& os, const std::vector& v) { os << "["; for (const auto& e : v) { os << e << ","; } return (os << "]" << std::endl); } using ll = long long; using ld = long double; template constexpr F PI() { return 3.1415926535897932385; } std::mt19937 mt{std::random_device{}()}; template class SegTree { static std::size_t SZ(const std::size_t n) { std::size_t ans = 1; for (; ans < n; ans <<= 1) {} return ans; } public: using BaseMonoid = Monoid; using T = typename Monoid::T; SegTree(const std::size_t n) : size(n), half(SZ(n)), value(half << 1, Monoid::id()) {} template SegTree(const InIt first, const InIt last) : size(distance(first, last)), half(SZ(size)), value(half << 1, Monoid::id()) { std::copy(first, last, value.begin() + half); for (std::size_t i = half - 1; i >= 1; i--) { up(i); } } T get(const std::size_t a) const { return value[a + half]; } void set(std::size_t a, const T& val) { value[a += half] = val; while (a >>= 1) { up(a); } } T accumulate(std::size_t L, std::size_t R) const { T accl = Monoid::id(), accr = Monoid::id(); for (L += half, R += half; L < R; L >>= 1, R >>= 1) { if (L & 1) { accl = acc(accl, value[L++]); } if (R & 1) { accr = acc(value[--R], accr); } } return acc(accl, accr); } template std::size_t partitionPoint(const std::size_t L, const std::size_t R, const Pred& pred) const { auto prec = [&](auto&& self, const std::size_t index, const std::size_t left, const std::size_t right, const T& offset) -> std::pair { if (right <= L or R <= left or pred(acc(offset, value[index]))) { return {Monoid::id(), R}; } if (index >= half) { return {value[index], index - half}; } const std::pair lans = self(self, index << 1, left, (left + right) >> 1, offset); if (lans.second != R) { return lans; } return self(self, index << 1 | 1, (left + right) >> 1, right, acc(offset, lans.first)); }; return prec(prec, 1, 0, half, Monoid::id()).second; } std::vector data() const { return std::vector(value.begin() + half, value.begin() + half + size); } private: void up(const std::size_t i) { value[i] = acc(value[i << 1], value[i << 1 | 1]); } const std::size_t size, half; std::vector value; const Monoid acc{}; }; template std::ostream& operator<<(std::ostream& os, const SegTree& seg) { os << "["; for (const auto e : seg.data()) { os << e << ","; } return (os << "]\n"); } template constexpr T INF() { return std::numeric_limits::max() / 16; } template struct Min { using T = X; T operator()(const T& a, const T& b) const { return std::min(a, b); } static constexpr T id() { return INF(); } }; int main() { int N, K; std::cin >> N >> K; std::vector a(N); std::string s; std::cin >> s; for (int i = 0; i < N; i++) { a[i] = s[i] - '0'; } using Seg = SegTree>; std::vector b(2 * N); auto ok = [&](const ld x) -> bool { for (int i = 0; i < N; i++) { b[i] = -a[i] + x, b[i + N] = b[i]; } for (int i = 1; i < 2 * N; i++) { b[i] += b[i - 1]; } Seg seg(b.begin(), b.end()); for (int i = 0; i < N; i++) { if (seg.accumulate(i + K, i + N) <= seg.get(i)) { return true; } } return false; }; ld inf = 0, sup = 1; for (int i = 0; i < 30; i++) { const ld mid = (inf + sup) / 2; (ok(mid) ? inf : sup) = mid; } std::cout << std::fixed << std::setprecision(15) << inf << std::endl; return 0; }