結果

問題 No.973 余興
ユーザー kotamanegikotamanegi
提出日時 2020-01-17 22:51:24
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 683 ms / 4,000 ms
コード長 2,153 bytes
コンパイル時間 2,572 ms
コンパイル使用メモリ 134,560 KB
実行使用メモリ 224,864 KB
最終ジャッジ日時 2023-08-20 13:45:30
合計ジャッジ時間 27,220 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 582 ms
223,016 KB
testcase_01 AC 579 ms
223,188 KB
testcase_02 AC 584 ms
224,636 KB
testcase_03 AC 587 ms
223,340 KB
testcase_04 AC 574 ms
224,192 KB
testcase_05 AC 572 ms
222,932 KB
testcase_06 AC 571 ms
223,064 KB
testcase_07 AC 591 ms
223,036 KB
testcase_08 AC 576 ms
222,848 KB
testcase_09 AC 578 ms
224,120 KB
testcase_10 AC 552 ms
224,140 KB
testcase_11 AC 264 ms
213,456 KB
testcase_12 AC 267 ms
213,544 KB
testcase_13 AC 264 ms
213,616 KB
testcase_14 AC 271 ms
213,368 KB
testcase_15 AC 81 ms
204,828 KB
testcase_16 AC 83 ms
204,928 KB
testcase_17 AC 74 ms
203,532 KB
testcase_18 AC 77 ms
203,392 KB
testcase_19 AC 78 ms
203,620 KB
testcase_20 AC 74 ms
202,280 KB
testcase_21 AC 81 ms
203,440 KB
testcase_22 AC 82 ms
205,012 KB
testcase_23 AC 77 ms
203,496 KB
testcase_24 AC 78 ms
203,180 KB
testcase_25 AC 70 ms
202,048 KB
testcase_26 AC 75 ms
202,676 KB
testcase_27 AC 87 ms
204,152 KB
testcase_28 AC 92 ms
203,256 KB
testcase_29 AC 91 ms
202,796 KB
testcase_30 AC 683 ms
223,092 KB
testcase_31 AC 649 ms
223,400 KB
testcase_32 AC 669 ms
223,176 KB
testcase_33 AC 657 ms
223,096 KB
testcase_34 AC 669 ms
223,028 KB
testcase_35 AC 665 ms
223,232 KB
testcase_36 AC 643 ms
223,400 KB
testcase_37 AC 655 ms
224,104 KB
testcase_38 AC 681 ms
223,088 KB
testcase_39 AC 672 ms
223,380 KB
testcase_40 AC 74 ms
198,856 KB
testcase_41 AC 75 ms
198,844 KB
testcase_42 AC 75 ms
199,180 KB
testcase_43 AC 76 ms
198,876 KB
testcase_44 AC 74 ms
199,592 KB
testcase_45 AC 74 ms
199,420 KB
testcase_46 AC 618 ms
224,864 KB
testcase_47 AC 620 ms
223,304 KB
testcase_48 AC 623 ms
223,284 KB
testcase_49 AC 592 ms
223,548 KB
testcase_50 AC 609 ms
223,004 KB
testcase_51 AC 668 ms
223,624 KB
testcase_52 AC 664 ms
222,920 KB
testcase_53 AC 675 ms
223,040 KB
testcase_54 AC 579 ms
224,464 KB
testcase_55 AC 600 ms
223,888 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:1:18: warning: '#pragma comment linker' ignored [-Wignored-pragmas]
#pragma comment (linker, "/STACK:256000000")
                 ^
1 warning generated.

ソースコード

diff #

#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()
void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(100);
}
bool ans[5000][5000] = {};
bool visited[5000][5000] = {};
int next_go[2][5000 * 5000] = {};
int union_find(int now, bool dir) {
	if (next_go[dir][now] == now) return now;
	return next_go[dir][now] = union_find(next_go[dir][now], dir);
}
pair<int, int> to_pair(int now) {
	return mp(now / 5000, now % 5000);
}
int to_int(pair<int,int> now) {
	return now.first * 5000 + now.second;
}
ll summing[7000] = {};
ll calc_sum(int a, int b) {
	return summing[b+1] - summing[a];
}
void solve() {
	ll n, x;
	cin >> n >> x;
	vector<ll> inputs;
	REP(i, n) {
		int a;
		cin >> a;
		inputs.pb(a);
	}
	for (int i = 0; i < inputs.size(); ++i) {
		summing[i + 1] += inputs[i] + summing[i];
	}
	for (int i = inputs.size(); i + 1 < 7000; ++i) {
		summing[i + 1] = summing[i];
	}
	REP(i, 5000) {
		REP(q, 5000) {
			next_go[0][i*5000+q] = next_go[1][i*5000+q] = i*5000+q;
		}
	}
	for (int q = 0; q < n; ++q) {
		for (int i = q; i >= 0; --i) {
			if (ans[i][q] == 1) continue;
			{
				//dir = 0
				while (true) {
					int next = union_find(i * 5000 + q, 0);
					if (next/5000 == 0) break;
					if (calc_sum(next/5000 - 1, i - 1) > x) break;
					ans[next/5000 - 1][next % 5000] = 1;
					next_go[0][next] = next - 5000;
				}
			}
			{
				//dir = 1
				while (true) {
					int next = union_find(i * 5000 + q, 1);
					if (next % 5000 == n-1) break;
					if (calc_sum(q+1, next % 5000 + 1) > x) break;
					ans[next / 5000][next % 5000 + 1] = 1;
					next_go[1][next] = next + 1;
				}
			}
		}
	}
	if (ans[0][n - 1] == 0) {
		cout << "B" << endl;
	}
	else {
		cout << "A" << endl;
	}
	return;
}

#undef int

int main() {
	init();
	solve();
}
0