結果
| 問題 | No.576 E869120 and Rings |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-04-23 20:47:49 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 823 bytes |
| 記録 | |
| コンパイル時間 | 2,012 ms |
| コンパイル使用メモリ | 338,896 KB |
| 実行使用メモリ | 9,416 KB |
| 最終ジャッジ日時 | 2026-07-10 04:18:42 |
| 合計ジャッジ時間 | 3,679 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 27 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int n,k;
double l,r=1,mid,a[1000005];
string s;
bool check(double x)
{
for(int i=0;i<n;i++)a[i+1]=a[i]+s[i]-'0'-x;
deque<pair<double,int> >q;
for(int i=1;i<=n/2;i++)
{
while(q.size()&&q.back().first<a[i])q.pop_back();
q.push_back(make_pair(a[i],i));
}
for(int i=0;i<n/2;i++)
{
while(q.size()&&q.front().second<=i+k-1)q.pop_front();
if(q.front().first>=a[i])return 1;
while(q.size()&&q.back().first<a[i+n/2+1])q.pop_back();
q.push_back(make_pair(a[i+n/2+1],i+n/2+1));
}
return 0;
}
int main()
{
freopen("sapphire.in","r",stdin);
freopen("sapphire.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n>>k>>s;
n<<=1;s+=s;
while(r-l>1e-13)
{
mid=(l+r)/2;
if(check(mid))l=mid;
else r=mid;
}
cout<<fixed<<setprecision(12)<<l;
}
vjudge1