結果

問題 No.1211 円環はお断り
ユーザー ChanyuhChanyuh
提出日時 2020-08-31 09:18:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,051 bytes
コンパイル時間 1,196 ms
コンパイル使用メモリ 133,396 KB
実行使用メモリ 35,500 KB
最終ジャッジ日時 2024-04-27 14:03:38
合計ジャッジ時間 11,141 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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>(20,0));
    rep(i,2*n+1){
        table[i][0]=lower_bound(S.begin(),S.end(),x+S[i])-S.begin();
        //cout << i << " " << table[i][0] << endl;
    }
    rep(j,20){
        table[2*n+1][j]=2*n+1;
    }
    rep(j,19){
        rep(i,2*n+1){
            table[i][j+1]=table[table[i][j]][j];
        }
    }
    rep(i,n){
        int pos=i;
        rep(j,20){
            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=INF;
    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