結果

問題 No.576 E869120 and Rings
ユーザー maspymaspy
提出日時 2020-05-09 01:07:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,131 bytes
コンパイル時間 504 ms
コンパイル使用メモリ 69,204 KB
実行使用メモリ 21,956 KB
最終ジャッジ日時 2023-09-17 05:13:35
合計ジャッジ時間 5,770 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 231 ms
21,132 KB
testcase_01 AC 206 ms
20,980 KB
testcase_02 AC 240 ms
20,980 KB
testcase_03 AC 256 ms
21,020 KB
testcase_04 AC 229 ms
20,980 KB
testcase_05 AC 230 ms
21,128 KB
testcase_06 AC 230 ms
20,972 KB
testcase_07 AC 241 ms
20,960 KB
testcase_08 AC 149 ms
21,208 KB
testcase_09 AC 145 ms
20,980 KB
testcase_10 AC 147 ms
21,084 KB
testcase_11 AC 135 ms
21,184 KB
testcase_12 AC 139 ms
20,980 KB
testcase_13 AC 127 ms
21,104 KB
testcase_14 AC 146 ms
21,108 KB
testcase_15 AC 89 ms
21,020 KB
testcase_16 AC 121 ms
21,956 KB
testcase_17 AC 136 ms
20,932 KB
testcase_18 AC 134 ms
21,016 KB
testcase_19 AC 133 ms
21,040 KB
testcase_20 AC 129 ms
21,000 KB
testcase_21 AC 134 ms
21,000 KB
testcase_22 AC 3 ms
7,688 KB
testcase_23 WA -
testcase_24 AC 2 ms
7,580 KB
testcase_25 AC 3 ms
7,576 KB
testcase_26 AC 2 ms
7,600 KB
testcase_27 AC 3 ms
7,712 KB
testcase_28 AC 2 ms
7,596 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
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 << l << endl;
    return 0;
}
0