結果

問題 No.1211 円環はお断り
ユーザー e869120e869120
提出日時 2021-02-26 09:13:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,005 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 68,096 KB
実行使用メモリ 47,700 KB
最終ジャッジ日時 2024-04-09 22:28:07
合計ジャッジ時間 10,226 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,756 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 1,258 ms
24,556 KB
testcase_14 AC 1,671 ms
31,164 KB
testcase_15 AC 1,638 ms
31,120 KB
testcase_16 TLE -
testcase_17 AC 191 ms
10,124 KB
testcase_18 AC 1,380 ms
27,252 KB
testcase_19 AC 209 ms
9,208 KB
testcase_20 AC 263 ms
11,900 KB
testcase_21 AC 251 ms
9,992 KB
testcase_22 AC 1,296 ms
26,308 KB
testcase_23 AC 1,545 ms
29,364 KB
testcase_24 AC 890 ms
20,720 KB
testcase_25 AC 39 ms
8,388 KB
testcase_26 AC 1,799 ms
33,752 KB
testcase_27 AC 905 ms
20,512 KB
testcase_28 AC 1,825 ms
32,988 KB
testcase_29 AC 1,463 ms
27,664 KB
testcase_30 AC 1,972 ms
35,412 KB
testcase_31 AC 795 ms
18,368 KB
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

long long N, K;
long long A[1 << 18], B[1 << 18];
long long par[1 << 18][22];

bool solve(long long border) {
	for (int i = 0; i <= 2 * N; i++) {
		int pos1 = lower_bound(B, B + 2 * N, B[i] + border) - B;
		par[i][0] = pos1;
	}
	for (int i = 0; i <= 20; i++) {
		for (int j = 0; j <= 2 * N; j++) par[j][i + 1] = par[par[j][i]][i];
	}

	for (int i = 0; i < N; i++) {
		int cx = i;
		for (int j = 20; j >= 0; j--) {
			if ((K / (1LL << j)) % 2 == 1) cx = par[cx][j];
		}
		if (cx <= i + N) return true;
	}
	return false;
}

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = N; i <= 2 * N; i++) A[i] = A[i - N];
	for (int i = 0; i <= 2 * N; i++) B[i + 1] = B[i] + A[i];

	long long cl = 0, cr = (1LL << 50), cm, maxn = 0;
	for (int i = 0; i < 53; i++) {
		cm = (cl + cr) / 2LL;
		bool I = solve(cm);
		if (I == true) { maxn = max(maxn, cm); cl = cm; }
		else { cr = cm; }
	}
	cout << maxn << endl;
	return 0;
}
0