結果

問題 No.1211 円環はお断り
ユーザー vwxyzvwxyz
提出日時 2023-03-31 04:15:02
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,628 bytes
コンパイル時間 2,950 ms
コンパイル使用メモリ 251,764 KB
実行使用メモリ 25,268 KB
最終ジャッジ日時 2023-10-23 17:52:35
合計ジャッジ時間 15,280 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,372 KB
testcase_07 AC 2 ms
4,372 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,372 KB
testcase_10 AC 2 ms
4,372 KB
testcase_11 AC 2 ms
4,372 KB
testcase_12 AC 2 ms
4,372 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 660 ms
25,184 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 656 ms
25,184 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 2 ms
4,372 KB
testcase_42 AC 2 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(2*N+1);
    int sum_A = 0;
    for (int i = 1; i < N+1; i++) {
        cin >> A[i];
        A[i+N]=A[i];
        sum_A += A[i];
    }
    for (int i = 1; i < 2*N+1; i++) {
        A[i] += A[i-1];
    }
    int ok = 0, ng = sum_A / K;
    while (abs(ok-ng) > 1) {
        int mid = (ok+ng) / 2;
        vector<int> perm(2*N+1);
        for (int i = 0; i < 2*N+1; i++) {
            perm[i] = i;
        }
        int r = 0;
        for (int l = 0; l < 2*N; l++) {
            while (r < 2*N && A[r]-A[l] < mid) {
                r++;
            }
            perm[l] = r;
        }
        int k = log2(K) + 1;
        vector<vector<int>> perm_doub(2*N+1, vector<int>(k));
        for (int n = 0; n < 2*N+1; n++) {
            perm_doub[n][0] = perm[n];
        }
        for (int kk = 1; kk < k; kk++) {
            for (int n = 0; n < 2*N+1; n++) {
                perm_doub[n][kk] = perm_doub[perm_doub[n][kk-1]][kk-1];
            }
        }
        bool found = false;
        for (int i = 0; i < N; i++) {
            int x = i;
            for (int kk = 0; kk < k; kk++) {
                if (K>>kk & 1) {
                    x = perm_doub[x][kk];
                }
            }
            if (mid < A[i]) {
                break;
            }
            if (i + 1 <= x && x <= i + N) {
                found = true;
                break;
            }
        }
        if(found){
            ok=mid;
        }
        else{
            ng = mid;
        }
    }
    cout << ok << endl;
    return 0;
}
0