結果

問題 No.973 余興
ユーザー kotamanegikotamanegi
提出日時 2020-01-17 22:51:24
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 601 ms / 4,000 ms
コード長 2,153 bytes
コンパイル時間 2,515 ms
コンパイル使用メモリ 165,336 KB
実行使用メモリ 222,984 KB
最終ジャッジ日時 2024-05-07 20:16:00
合計ジャッジ時間 23,444 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 508 ms
222,984 KB
testcase_01 AC 507 ms
222,852 KB
testcase_02 AC 514 ms
222,856 KB
testcase_03 AC 502 ms
222,852 KB
testcase_04 AC 533 ms
222,980 KB
testcase_05 AC 530 ms
222,980 KB
testcase_06 AC 515 ms
222,856 KB
testcase_07 AC 511 ms
222,852 KB
testcase_08 AC 507 ms
222,980 KB
testcase_09 AC 504 ms
222,980 KB
testcase_10 AC 509 ms
222,464 KB
testcase_11 AC 249 ms
213,120 KB
testcase_12 AC 247 ms
212,992 KB
testcase_13 AC 243 ms
213,120 KB
testcase_14 AC 244 ms
213,120 KB
testcase_15 AC 76 ms
203,264 KB
testcase_16 AC 75 ms
203,264 KB
testcase_17 AC 70 ms
202,240 KB
testcase_18 AC 76 ms
202,880 KB
testcase_19 AC 74 ms
202,752 KB
testcase_20 AC 70 ms
202,240 KB
testcase_21 AC 78 ms
203,392 KB
testcase_22 AC 76 ms
203,392 KB
testcase_23 AC 72 ms
202,880 KB
testcase_24 AC 74 ms
202,752 KB
testcase_25 AC 65 ms
201,344 KB
testcase_26 AC 70 ms
202,112 KB
testcase_27 AC 77 ms
203,776 KB
testcase_28 AC 72 ms
202,752 KB
testcase_29 AC 73 ms
202,624 KB
testcase_30 AC 580 ms
222,976 KB
testcase_31 AC 599 ms
222,720 KB
testcase_32 AC 601 ms
222,976 KB
testcase_33 AC 583 ms
222,976 KB
testcase_34 AC 568 ms
222,976 KB
testcase_35 AC 597 ms
222,976 KB
testcase_36 AC 576 ms
222,464 KB
testcase_37 AC 571 ms
222,592 KB
testcase_38 AC 574 ms
222,976 KB
testcase_39 AC 575 ms
222,976 KB
testcase_40 AC 57 ms
198,784 KB
testcase_41 AC 58 ms
198,804 KB
testcase_42 AC 57 ms
198,912 KB
testcase_43 AC 57 ms
198,784 KB
testcase_44 AC 57 ms
198,912 KB
testcase_45 AC 57 ms
199,168 KB
testcase_46 AC 549 ms
222,848 KB
testcase_47 AC 549 ms
222,976 KB
testcase_48 AC 550 ms
222,976 KB
testcase_49 AC 503 ms
221,952 KB
testcase_50 AC 534 ms
222,848 KB
testcase_51 AC 552 ms
222,976 KB
testcase_52 AC 561 ms
222,976 KB
testcase_53 AC 555 ms
222,720 KB
testcase_54 AC 544 ms
222,848 KB
testcase_55 AC 542 ms
222,848 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:1:18: warning: '#pragma comment linker' ignored [-Wignored-pragmas]
    1 | #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