結果
| 問題 | No.576 E869120 and Rings |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-11-08 14:36:48 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 834 bytes |
| 記録 | |
| コンパイル時間 | 2,811 ms |
| コンパイル使用メモリ | 347,780 KB |
| 実行使用メモリ | 29,912 KB |
| 最終ジャッジ日時 | 2026-11-08 14:38:03 |
| 合計ジャッジ時間 | 74,928 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 TLE * 22 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace std;
using SS = double;
SS op(SS a, SS b) { return min(a, b); }
SS e() { return 1e18; }
int main() {
int N, K;
cin >> N >> K;
vector<int> A(N);
{
string S;
cin >> S;
for(int i = 0; i < N; i++) A[i] = S[i] == '1';
}
auto check = [&](double x) {
vector<double> S(N + N + 1);
for(int i = 0; i < N+N; i++) S[i + 1] = S[i] + A[i%N];
for(int i = 0; i < N+N+1; i++) S[i] -= x * i;
atcoder::segtree<SS, op, e> seg(S);
double t = 1e18;
for(int j = K; j < N+N+1; j++) {
int l = max(0,j-N);
int r = j - K;
if(S[j]>=seg.prod(l,r+1)) return true;
}
return false;
};
double ok = 0, ng = 1.1;
for(int it = 0; it < 80; it++) {
double m = (ok + ng) / 2.;
(check(m) ? ok : ng) = m;
}
cout << fixed << setprecision(16) << ok << endl;
}