結果

問題 No.1211 円環はお断り
ユーザー ChanyuhChanyuh
提出日時 2020-08-31 09:25:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,078 bytes
コンパイル時間 1,489 ms
コンパイル使用メモリ 132,344 KB
実行使用メモリ 25,860 KB
最終ジャッジ日時 2023-08-15 10:15:34
合計ジャッジ時間 30,159 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 667 ms
14,912 KB
testcase_14 AC 1,149 ms
18,816 KB
testcase_15 AC 945 ms
18,284 KB
testcase_16 AC 1,592 ms
25,392 KB
testcase_17 AC 96 ms
5,084 KB
testcase_18 AC 846 ms
16,508 KB
testcase_19 AC 100 ms
5,112 KB
testcase_20 AC 138 ms
5,876 KB
testcase_21 AC 127 ms
5,748 KB
testcase_22 AC 706 ms
15,272 KB
testcase_23 AC 832 ms
17,624 KB
testcase_24 AC 439 ms
11,296 KB
testcase_25 AC 18 ms
4,380 KB
testcase_26 AC 1,031 ms
19,612 KB
testcase_27 AC 451 ms
11,416 KB
testcase_28 AC 1,113 ms
20,048 KB
testcase_29 AC 774 ms
16,500 KB
testcase_30 AC 1,078 ms
20,792 KB
testcase_31 AC 403 ms
10,464 KB
testcase_32 AC 1,355 ms
23,664 KB
testcase_33 AC 1,584 ms
25,680 KB
testcase_34 AC 1,545 ms
25,768 KB
testcase_35 AC 1,561 ms
25,628 KB
testcase_36 AC 1,576 ms
25,592 KB
testcase_37 AC 1,507 ms
25,860 KB
testcase_38 AC 1,555 ms
25,652 KB
testcase_39 AC 1,515 ms
25,616 KB
testcase_40 TLE -
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n,k;
ll a[100010];
vector<ll> S;

bool check(ll x){
    vector<vector<int>> table(2*n+2,vector<int>(18,0));
    int r=0;
    rep(i,2*n+1){
        while(S[r]-S[i]<x){
            r++;
        }
        table[i][0]=r;
        //cout << i << " " << table[i][0] << endl;
    }
    rep(j,18){
        table[2*n+1][j]=2*n+1;
    }
    rep(j,17){
        rep(i,2*n+1){
            table[i][j+1]=table[table[i][j]][j];
        }
    }
    rep(i,n){
        int pos=i;
        rep(j,17){
            if(k&(1 << j)) pos=table[pos][j];
        }
        if(pos<=i+n){
            return true;
        }
    }
    return false;
}

void solve(){
    cin >> n >> k;
    rep(i,n) cin >> a[i];
    S.resize(2*n+2);
    rep(i,n){
        S[i+1]=S[i]+a[i];
    }
    rep(i,n){
        S[i+n+1]=S[i+n]+a[i];
    }
    S[2*n+1]=INF;
    ll l=0,r=S[n]/k+3;
    while(r-l>1){
        ll mid=(l+r)/2;
        if(check(mid)) l=mid;
        else r=mid;
    }
    cout << l << endl;
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}
0