結果
| 問題 |
No.576 E869120 and Rings
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-04-22 19:01:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,145 bytes |
| コンパイル時間 | 1,729 ms |
| コンパイル使用メモリ | 168,156 KB |
| 実行使用メモリ | 20,688 KB |
| 最終ジャッジ日時 | 2025-04-22 19:01:32 |
| 合計ジャッジ時間 | 8,094 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 25 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef double f64;
const int N = 1e6 + 10;
const f64 eps = 1e-6;
int n, k;
string s;
f64 a[N], sum[N];
inline bool check(f64 x)
{
for (int i = 1; i <= n; i++)
a[i] = a[i + n] = (s[i] - '0' - x);
for (int i = 1; i <= 2 * n; i++)
sum[i] = sum[i - 1] + a[i];
deque<int> q;
q.push_back(0);
for (int i = k; i <= 2 * n; i++)
{
while (!q.empty() && i - q.front() > n)
q.pop_front();
int j = q.front();
if (sum[i] - sum[j] > eps)
return 1;
while (!q.empty() && sum[q.back()] - sum[i - k + 1] > eps)
q.pop_back();
q.push_back(i - k + 1);
}
return 0;
}
int main(int argc, char const *argv[])
{
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
cin >> n >> k >> s;
s = ' ' + s;
f64 l = 0, r = 1, ans = l;
while (r - l > eps)
{
f64 mid = (l + r) / 2;
if (check(mid))
ans = mid, l = mid;
else
r = mid;
}
cout << fixed << setprecision(6) << ans << endl;
return 0;
}
vjudge1