結果

問題 No.973 余興
ユーザー FF256grhyFF256grhy
提出日時 2020-01-18 15:04:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 2,851 bytes
コンパイル時間 2,218 ms
コンパイル使用メモリ 182,936 KB
実行使用メモリ 683,236 KB
最終ジャッジ日時 2023-09-09 22:16:21
合計ジャッジ時間 13,322 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

template<typename T> T MV(T v) { return v; }
template<typename T, typename... R> auto MV(T v, int s, R... r) { return vector<decltype(MV(v, r...))>(s, MV(v, r...)); }

#define LB(v, x) (lower_bound(ALL(v), x) - v.begin())
#define UB(v, x) (upper_bound(ALL(v), x) - v.begin())

int main() {
	LL n, x;
	cin >> n >> x;
	vector<LL> a(n), s(n + 1);
	inc(i, n) { cin >> a[i]; }
	inc(i, n) { s[i + 1] = s[i] + a[i]; }
	
	auto dp = MV(0, 2, n + 1, n + 1);
	vector<array<int, 3>> p;
	incII(i, 0, n) {
	incII(j, 0, n) {
		if(j - i > 0) { p.PB({ j - i, i, j }); }
	}
	}
	sort(ALL(p));
	
	incII(i, 0, n) { dp[0][i][i] = dp[1][i][i] = 1; }
	inc(i, n) { dp[0][i][i + 1] = dp[1][i][i + 1] = -1; }
	RF(e, p) {
		int i = e[1];
		int j = e[2];
		
		dp[0][i][j] += dp[0][i + 1][j];
		if(dp[0][i][j] == 0) {
			int r = UB(s, s[i + 1] + x);
			if(j + 1 <= n) { dp[1][i][j + 1]++; }
			if(r     <= n) { dp[1][i][r    ]--; }
		}
		
		dp[1][i][j] += dp[1][i][j - 1];
		if(dp[1][i][j] == 0) {
			int l = LB(s, s[i] - x);
			if(0 <= i - 1) { dp[0][i - 1][j]++; }
			if(0 <= l - 1) { dp[0][l - 1][j]--; }
		}
	}
	
	cout << (dp[0][0][n] != 0 ? "A" : "B") << endl;
	
	return 0;
}
0