結果

問題 No.1211 円環はお断り
ユーザー RhoRho
提出日時 2020-08-24 22:26:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 633 ms / 2,000 ms
コード長 910 bytes
コンパイル時間 1,517 ms
コンパイル使用メモリ 164,836 KB
実行使用メモリ 37,200 KB
最終ジャッジ日時 2023-08-15 09:52:04
合計ジャッジ時間 11,071 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
34,108 KB
testcase_01 AC 7 ms
34,324 KB
testcase_02 AC 7 ms
34,060 KB
testcase_03 AC 8 ms
34,124 KB
testcase_04 AC 8 ms
34,164 KB
testcase_05 AC 8 ms
34,096 KB
testcase_06 AC 8 ms
34,336 KB
testcase_07 AC 8 ms
34,052 KB
testcase_08 AC 8 ms
34,328 KB
testcase_09 AC 8 ms
34,104 KB
testcase_10 AC 8 ms
34,108 KB
testcase_11 AC 8 ms
34,164 KB
testcase_12 AC 8 ms
34,092 KB
testcase_13 AC 208 ms
35,748 KB
testcase_14 AC 341 ms
36,252 KB
testcase_15 AC 276 ms
36,136 KB
testcase_16 AC 423 ms
36,864 KB
testcase_17 AC 38 ms
34,428 KB
testcase_18 AC 258 ms
36,036 KB
testcase_19 AC 40 ms
34,448 KB
testcase_20 AC 50 ms
34,528 KB
testcase_21 AC 46 ms
34,548 KB
testcase_22 AC 216 ms
35,900 KB
testcase_23 AC 254 ms
36,112 KB
testcase_24 AC 143 ms
35,440 KB
testcase_25 AC 16 ms
34,224 KB
testcase_26 AC 300 ms
36,252 KB
testcase_27 AC 140 ms
35,552 KB
testcase_28 AC 311 ms
36,332 KB
testcase_29 AC 242 ms
35,968 KB
testcase_30 AC 319 ms
36,396 KB
testcase_31 AC 133 ms
35,580 KB
testcase_32 AC 378 ms
36,956 KB
testcase_33 AC 416 ms
36,924 KB
testcase_34 AC 414 ms
36,980 KB
testcase_35 AC 418 ms
36,940 KB
testcase_36 AC 410 ms
37,000 KB
testcase_37 AC 396 ms
37,184 KB
testcase_38 AC 423 ms
37,200 KB
testcase_39 AC 422 ms
36,956 KB
testcase_40 AC 633 ms
36,948 KB
testcase_41 AC 8 ms
34,100 KB
testcase_42 AC 8 ms
34,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define rep(i,n)for(int i=0;i<(int)(n);i++)
using namespace std;
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef pair<ll,ll>P;
#define vi vector<ll>
const ll inf=1ll<<61;
ll a[100006];
ll rwa[200005];
ll to[20][200005];
signed main(){
	ll n,k;cin>>n>>k;
	ll S=0;
	rep(i,n){
		cin>>a[i];
		rwa[i+1]=rwa[i+n+1]=a[i];
		S+=a[i];
	}
	rep(i,n+n)rwa[i+1]+=rwa[i];

	ll lb=0,ub=(S/k)+1;
	while(ub-lb>1){
		//全員がmi以上保持できるか?
		ll mi=(ub+lb)/2;

		rep(i,n){
			auto itr=lower_bound(rwa,rwa+n+n+1,rwa[i]+mi);
			to[0][i]=itr-rwa;
			to[0][i+n]=to[0][i]+n;
			if(to[0][i+n]>=n+n)to[0][i+n]=n+n;
		}
		to[0][n+n]=n+n;
		rep(i,19){
			rep(j,n+n+1){
				to[i+1][j]=to[i][to[i][j]];
			}
		}
		int ok=0;
		rep(i,n){
			int now=i;
			rep(j,19){
				if(k&(1<<j))now=to[j][now];
			}
			if(i<now&&now<=i+n)ok++;
		}

		if(ok)lb=mi;
		else ub=mi;
	}
	cout<<lb<<endl;
}
0