結果

問題 No.1211 円環はお断り
ユーザー chocoruskchocorusk
提出日時 2020-08-30 22:44:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 680 ms / 2,000 ms
コード長 1,303 bytes
コンパイル時間 1,279 ms
コンパイル使用メモリ 126,404 KB
実行使用メモリ 19,956 KB
最終ジャッジ日時 2023-08-15 10:10:28
合計ジャッジ時間 14,278 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
17,672 KB
testcase_01 AC 4 ms
17,672 KB
testcase_02 AC 4 ms
17,760 KB
testcase_03 AC 4 ms
17,668 KB
testcase_04 AC 4 ms
17,676 KB
testcase_05 AC 5 ms
17,672 KB
testcase_06 AC 4 ms
17,680 KB
testcase_07 AC 4 ms
17,704 KB
testcase_08 AC 4 ms
17,676 KB
testcase_09 AC 4 ms
17,944 KB
testcase_10 AC 4 ms
17,808 KB
testcase_11 AC 5 ms
17,668 KB
testcase_12 AC 4 ms
17,692 KB
testcase_13 AC 318 ms
18,668 KB
testcase_14 AC 425 ms
19,516 KB
testcase_15 AC 424 ms
19,104 KB
testcase_16 AC 627 ms
19,760 KB
testcase_17 AC 52 ms
18,052 KB
testcase_18 AC 361 ms
19,044 KB
testcase_19 AC 52 ms
17,812 KB
testcase_20 AC 66 ms
17,940 KB
testcase_21 AC 65 ms
18,132 KB
testcase_22 AC 327 ms
18,900 KB
testcase_23 AC 376 ms
18,972 KB
testcase_24 AC 226 ms
18,964 KB
testcase_25 AC 16 ms
17,740 KB
testcase_26 AC 450 ms
19,152 KB
testcase_27 AC 225 ms
18,580 KB
testcase_28 AC 500 ms
19,236 KB
testcase_29 AC 376 ms
18,856 KB
testcase_30 AC 492 ms
19,304 KB
testcase_31 AC 200 ms
18,404 KB
testcase_32 AC 593 ms
19,516 KB
testcase_33 AC 653 ms
19,800 KB
testcase_34 AC 658 ms
19,732 KB
testcase_35 AC 672 ms
19,776 KB
testcase_36 AC 650 ms
19,732 KB
testcase_37 AC 652 ms
19,732 KB
testcase_38 AC 678 ms
19,948 KB
testcase_39 AC 680 ms
19,956 KB
testcase_40 AC 279 ms
19,740 KB
testcase_41 AC 4 ms
17,736 KB
testcase_42 AC 4 ms
17,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, k; cin>>n>>k;
	ll a[200020];
	ll s[200020];
	for(int i=0; i<n; i++){
		cin>>a[i];
		a[i+n]=a[i];
	}
	s[0]=0;
	for(int i=0; i<2*n; i++) s[i+1]=s[i]+a[i];
	ll l=1, r=1.1e14;
	while(r-l>1){
		ll m=(l+r)/2;
		if(m>s[n]){
			r=m;
			continue;
		}
		int nx[17][200020];
		nx[0][2*n]=2*n;
		for(int i=0; i<2*n; i++){
			nx[0][i]=lower_bound(s, s+2*n, s[i]+m)-s;
		}
		for(int i=1; i<17; i++){
			nx[i][2*n]=2*n;
			for(int j=0; j<2*n; j++){
				nx[i][j]=nx[i-1][nx[i-1][j]];
			}
		}
		bool ok=0;
		for(int i=0; i<n; i++){
			int t=i;
			for(int j=16; j>=0; j--){
				if(k&(1<<j)){
					t=nx[j][t];
				}
			}
			if(t<=i+n){
				ok=1; break;
			}
		}
		if(ok) l=m;
		else r=m;
	}
	cout<<l<<endl;
	return 0;
}
0