結果
問題 |
No.576 E869120 and Rings
|
ユーザー |
![]() |
提出日時 | 2017-10-13 22:49:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 956 bytes |
コンパイル時間 | 2,361 ms |
コンパイル使用メモリ | 202,108 KB |
最終ジャッジ日時 | 2025-01-05 03:14:47 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 TLE * 21 |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long int64; int main() { int64 N, K; string A; cin >> N >> K; cin >> A; auto check = [&](double k) { int sum = 0; queue< double > lazy, lazy2; multiset< double > bit; bit.emplace(1e9); lazy.emplace(0.0); lazy2.emplace(0.0); for(int i = 0; i < N + N; i++) { if(K <= i + 1) { bit.emplace(lazy.front()); lazy.pop(); } if(K <= i + 1 - N) { bit.erase(bit.find(lazy2.front())); lazy2.pop(); } sum += A[i % N] - '0'; if(*bit.begin() <= sum - (i + 1) * k) return (true); lazy.emplace(sum - (i + 1) * k); lazy2.emplace(sum - (i + 1) * k); } return (false); }; double low = 0.0, high = 1.0; for(int i = 0; i < 44; i++) { double mid = (low + high) * 0.5; if(check(mid)) low = mid; else high = mid; } cout << fixed << setprecision(10) << low << endl; }