#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair P; int main() { int n, k; cin>>n>>k; string a; cin>>a; a+=a; double x1=0, x2=1; for(int t=0; t<50; t++){ double x=(x1+x2)/2; double s[1000010]; s[0]=0; deque deq; for(int i=0; i<2*n; i++){ if(a[i]=='1') s[i+1]=s[i]+1-x; else s[i+1]=s[i]-x; } bool ok=0; for(int i=k; i<=2*n; i++){ while(!deq.empty()){ if(s[deq.back()]<=s[i]) deq.pop_back(); else break; } deq.push_back(i); if(i>=n && s[deq.front()]>=s[i-n]){ ok=1; break; } if(deq.front()==i-n+k) deq.pop_front(); } if(ok) x1=x; else x2=x; } printf("%.7lf\n", x1); return 0; }