結果

問題 No.1211 円環はお断り
ユーザー RhoRho
提出日時 2020-08-24 22:34:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 656 ms / 2,000 ms
コード長 987 bytes
コンパイル時間 1,767 ms
コンパイル使用メモリ 167,992 KB
実行使用メモリ 37,120 KB
最終ジャッジ日時 2024-05-02 21:23:04
合計ジャッジ時間 11,699 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 222 ms
20,864 KB
testcase_14 AC 362 ms
26,752 KB
testcase_15 AC 290 ms
26,112 KB
testcase_16 AC 433 ms
36,608 KB
testcase_17 AC 36 ms
6,528 KB
testcase_18 AC 269 ms
23,552 KB
testcase_19 AC 37 ms
6,656 KB
testcase_20 AC 49 ms
7,424 KB
testcase_21 AC 45 ms
7,424 KB
testcase_22 AC 226 ms
21,760 KB
testcase_23 AC 267 ms
24,704 KB
testcase_24 AC 151 ms
15,616 KB
testcase_25 AC 11 ms
5,376 KB
testcase_26 AC 319 ms
28,032 KB
testcase_27 AC 152 ms
15,872 KB
testcase_28 AC 322 ms
28,544 KB
testcase_29 AC 251 ms
23,296 KB
testcase_30 AC 331 ms
29,696 KB
testcase_31 AC 132 ms
14,208 KB
testcase_32 AC 384 ms
34,048 KB
testcase_33 AC 434 ms
37,120 KB
testcase_34 AC 427 ms
36,988 KB
testcase_35 AC 425 ms
37,120 KB
testcase_36 AC 425 ms
37,116 KB
testcase_37 AC 411 ms
37,120 KB
testcase_38 AC 439 ms
37,116 KB
testcase_39 AC 438 ms
36,992 KB
testcase_40 AC 656 ms
37,116 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 2 ms
5,376 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;

	assert(1<=k&&k<=n&&n<=100000);
	rep(i,n)assert(1<=a[i]&&a[i]<=1000000000);
}
0