結果
| 問題 | No.576 E869120 and Rings |
| コンテスト | |
| ユーザー |
ei1333333
|
| 提出日時 | 2017-10-13 22:49:21 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 956 bytes |
| 記録 | |
| コンパイル時間 | 1,462 ms |
| コンパイル使用メモリ | 220,260 KB |
| 実行使用メモリ | 49,616 KB |
| 最終ジャッジ日時 | 2026-06-06 18:44:25 |
| 合計ジャッジ時間 | 7,342 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 26 |
ソースコード
#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;
}
ei1333333