結果
問題 |
No.576 E869120 and Rings
|
ユーザー |
![]() |
提出日時 | 2025-04-23 20:47:49 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 823 bytes |
コンパイル時間 | 3,634 ms |
コンパイル使用メモリ | 280,344 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-04-23 20:47:55 |
合計ジャッジ時間 | 5,532 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:26:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | freopen("sapphire.in","r",stdin); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:27:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | freopen("sapphire.out","w",stdout); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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; }