結果

問題 No.1211 円環はお断り
ユーザー milanis48663220milanis48663220
提出日時 2020-08-31 01:17:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,626 bytes
コンパイル時間 833 ms
コンパイル使用メモリ 86,308 KB
実行使用メモリ 20,148 KB
最終ジャッジ日時 2024-04-27 13:53:10
合計ジャッジ時間 10,782 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 705 ms
12,712 KB
testcase_14 AC 893 ms
15,052 KB
testcase_15 AC 944 ms
15,512 KB
testcase_16 AC 1,442 ms
20,044 KB
testcase_17 AC 102 ms
6,940 KB
testcase_18 AC 903 ms
15,644 KB
testcase_19 AC 114 ms
6,944 KB
testcase_20 AC 140 ms
6,944 KB
testcase_21 AC 137 ms
9,148 KB
testcase_22 AC 743 ms
15,436 KB
testcase_23 AC 817 ms
15,928 KB
testcase_24 AC 452 ms
10,740 KB
testcase_25 AC 26 ms
6,940 KB
testcase_26 AC 1,018 ms
17,908 KB
testcase_27 AC 466 ms
10,260 KB
testcase_28 AC 1,109 ms
17,652 KB
testcase_29 AC 827 ms
15,304 KB
testcase_30 AC 991 ms
19,872 KB
testcase_31 AC 448 ms
10,556 KB
testcase_32 AC 1,287 ms
19,776 KB
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 AC 1,173 ms
20,148 KB
testcase_41 AC 2 ms
6,944 KB
testcase_42 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

const ll INF = 1e15;

int N, K;
ll A[100005];

ll next_offset[100005][20];
bool used[100005];

void clear_used(){
    for(int i = 0; i < N; i++) used[i] = false;
}

void build(ll m){
    ll sum_sect = 0;
    int r = -1;
    for(int i = 0; i < N; i++){
        while(sum_sect < m){
            r++;
            if(r >= 2*N) sum_sect = INF;
            sum_sect += A[r%N];
        }
        next_offset[i][0] = r-i+1;
        sum_sect -= A[i];
    }
    for(int j = 1; j < 17; j++){
        for(int i = 0; i < N; i++){
            next_offset[i][j] = next_offset[i][j-1]+next_offset[(i+next_offset[i][j-1])%N][j-1];
        }
    }
}

vector<int> bt;

ll cnt(int s){
    ll ans = 0;
    for(int i : bt){
        used[s] = true;
        ans += next_offset[s][i];
        s += next_offset[s][i];
        s %= N;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> K;
    for(int i = 0; i < 17; i++){
        if(K&(1<<i)) bt.push_back(i);
    }
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    ll l = 1, r = INF;
    
    while(r-l > 1){
        ll c = (l+r)/2;
        clear_used();
        build(c);
        bool ok = false;
        for(int i = 0; i < N; i++){
            if(!used[i]){
                ll tmp = cnt(i);
                if(tmp <= N) ok = true;
            }
        }
        if(ok) l = c;
        else r = c;
    }
    cout << l << endl;
}
0