結果

問題 No.1211 円環はお断り
ユーザー MisterMister
提出日時 2020-08-30 17:13:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,535 bytes
コンパイル時間 792 ms
コンパイル使用メモリ 79,132 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-04-27 11:38:19
合計ジャッジ時間 17,560 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 431 ms
7,936 KB
testcase_14 AC 500 ms
9,348 KB
testcase_15 AC 533 ms
9,344 KB
testcase_16 WA -
testcase_17 AC 64 ms
6,944 KB
testcase_18 AC 576 ms
8,704 KB
testcase_19 AC 76 ms
6,940 KB
testcase_20 AC 85 ms
6,940 KB
testcase_21 AC 79 ms
6,944 KB
testcase_22 AC 433 ms
8,072 KB
testcase_23 AC 464 ms
8,832 KB
testcase_24 AC 260 ms
6,940 KB
testcase_25 AC 15 ms
6,944 KB
testcase_26 AC 587 ms
9,728 KB
testcase_27 AC 278 ms
6,940 KB
testcase_28 AC 663 ms
9,856 KB
testcase_29 AC 493 ms
8,576 KB
testcase_30 WA -
testcase_31 AC 280 ms
6,944 KB
testcase_32 WA -
testcase_33 AC 876 ms
12,288 KB
testcase_34 AC 883 ms
12,160 KB
testcase_35 AC 847 ms
12,288 KB
testcase_36 AC 790 ms
12,160 KB
testcase_37 AC 815 ms
12,288 KB
testcase_38 AC 807 ms
12,288 KB
testcase_39 AC 803 ms
12,160 KB
testcase_40 AC 681 ms
12,288 KB
testcase_41 AC 2 ms
6,944 KB
testcase_42 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <numeric>
#include <vector>

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

using lint = long long;

void solve() {
    int n, k;
    std::cin >> n >> k;

    std::vector<lint> xs(n);
    for (auto& x : xs) std::cin >> x;

    lint ok = 0, ng = std::accumulate(xs.begin(), xs.end(), 0LL) + 1;
    while (ng - ok > 1) {
        lint mid = (ok + ng) / 2;

        auto to = vec(20, vec(n, 0));
        {
            int r = 0;
            lint sum = 0;
            for (int l = 0; l < n; ++l) {
                while (sum < mid) {
                    sum += xs[r % n];
                    ++r;
                }
                to[0][l] = r - l;
                sum -= xs[l];
            }
        }

        for (int d = 0; d + 1 < 20; ++d) {
            for (int i = 0; i < n; ++i) {
                to[d + 1][i] = to[d][i] + to[d][(i + to[d][i]) % n];
            }
        }

        bool judge = false;
        for (int s = 0; s < n; ++s) {
            int v = s;
            lint sum = 0;

            for (int d = 0; d < 20; ++d) {
                if ((~k >> d) & 1) continue;
                sum += to[d][v];
                (v += to[d][v]) %= n;
            }

            if (sum <= n) judge = true;
        }

        if (judge) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    std::cout << ok << "\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0