結果

問題 No.1211 円環はお断り
ユーザー e869120e869120
提出日時 2021-02-26 09:17:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,019 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 68,012 KB
実行使用メモリ 41,900 KB
最終ジャッジ日時 2024-04-09 22:32:15
合計ジャッジ時間 8,803 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1,083 ms
25,140 KB
testcase_14 AC 1,420 ms
30,816 KB
testcase_15 AC 1,463 ms
30,320 KB
testcase_16 TLE -
testcase_17 AC 163 ms
10,296 KB
testcase_18 AC 1,215 ms
28,528 KB
testcase_19 AC 179 ms
10,556 KB
testcase_20 AC 218 ms
11,604 KB
testcase_21 AC 216 ms
9,728 KB
testcase_22 AC 1,137 ms
25,496 KB
testcase_23 AC 1,337 ms
29,312 KB
testcase_24 AC 776 ms
20,480 KB
testcase_25 AC 34 ms
6,948 KB
testcase_26 AC 1,625 ms
33,164 KB
testcase_27 AC 777 ms
22,092 KB
testcase_28 AC 1,681 ms
33,632 KB
testcase_29 AC 1,307 ms
27,340 KB
testcase_30 AC 1,840 ms
35,252 KB
testcase_31 AC 675 ms
17,408 KB
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 TLE -
testcase_39 TLE -
testcase_40 TLE -
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 3 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

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) {
	int pos1 = 0;
	for (int i = 0; i <= 2 * N; i++) {
		while (pos1 < 2 * N && B[i] + border > B[pos1]) pos1++;
		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