結果

問題 No.576 E869120 and Rings
ユーザー kimiyukikimiyuki
提出日時 2017-10-13 23:51:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,081 bytes
コンパイル時間 1,340 ms
コンパイル使用メモリ 94,520 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 17:46:46
合計ジャッジ時間 29,012 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1,150 ms
6,940 KB
testcase_07 WA -
testcase_08 AC 1,144 ms
6,940 KB
testcase_09 WA -
testcase_10 AC 1,146 ms
6,940 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1,116 ms
6,944 KB
testcase_15 AC 1,114 ms
6,940 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1,143 ms
6,940 KB
testcase_20 AC 1,142 ms
6,944 KB
testcase_21 WA -
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 2 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <algorithm>
#include <array>
#include <bitset>
#include <cstdio>
#include <random>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }

constexpr int MAX_N = 500000;
char a[2 * MAX_N];
default_random_engine gen;
int main() {
    int n, k; scanf("%d%d", &n, &k);
    repeat (i, n) {
        char a_i; scanf(" %c", &a_i);
        a[i] = a[n + i] = (a_i == '1');
    }
    double result = 0;
    repeat_from (len, k, n + 1) {
        if (abs(len - k) >= 1000 and abs(n - len) >= 1000 and not bernoulli_distribution(0.001)(gen)) continue;
        int cnt = 0;
        repeat (i, len) cnt += a[i];
        int max_cnt = cnt;
        repeat (i, n) {
            cnt += - a[i] + a[i + len];
            setmax(max_cnt, cnt);
        }
        setmax(result, max_cnt /(double) len);
    }
    printf("%.15lf\n", result);
    return 0;
}
0