結果
| 問題 |
No.576 E869120 and Rings
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-05-09 01:08:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 282 ms / 1,500 ms |
| コード長 | 1,179 bytes |
| コンパイル時間 | 800 ms |
| コンパイル使用メモリ | 73,036 KB |
| 最終ジャッジ日時 | 2025-01-10 09:30:04 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <iomanip>
using namespace std;
#define U 500010
double A[U + U];
double Acum[U + U];
int deq[U + U];
int N, K;
bool test(double x)
{
Acum[0] = 0;
for (int i = 0; i < N + N; i++)
{
Acum[i + 1] = Acum[i] + A[i] - x;
}
int l = 0;
int r = 0;
deq[0] = 0;
for (int k = K; k <= N + N; k++)
{
while (deq[l] < k - N)
{
l++;
}
double x = Acum[k];
if (x > Acum[deq[l]])
{
return true;
}
int i = k - K + 1;
x = Acum[i];
while (l <= r && Acum[deq[r]] > x)
{
r--;
}
r++;
deq[r] = i;
}
return false;
}
int main()
{
cin >> N >> K;
for (int i = 0; i < N; i++)
{
char c;
cin >> c;
A[i] = c - 48.0;
A[i + N] = c - 48.0;
}
double l = 0.0;
double r = 1.0;
for (int i = 0; i < 20; i++)
{
double m = (l + r) / 2;
if (test(m))
{
l = m;
}
else
{
r = m;
}
}
cout << fixed << setprecision(15) << l << endl;
return 0;
}
maspy