結果

問題 No.973 余興
ユーザー kwm_tkwm_t
提出日時 2023-06-30 15:28:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,979 bytes
コンパイル時間 2,125 ms
コンパイル使用メモリ 205,252 KB
実行使用メモリ 199,092 KB
最終ジャッジ日時 2023-09-21 09:03:23
合計ジャッジ時間 29,001 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 731 ms
199,000 KB
testcase_01 AC 731 ms
198,996 KB
testcase_02 AC 729 ms
199,088 KB
testcase_03 AC 733 ms
198,724 KB
testcase_04 AC 733 ms
198,876 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 692 ms
191,076 KB
testcase_11 AC 193 ms
73,492 KB
testcase_12 AC 204 ms
73,540 KB
testcase_13 WA -
testcase_14 AC 202 ms
72,988 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 11 ms
8,008 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 18 ms
10,912 KB
testcase_23 AC 13 ms
9,380 KB
testcase_24 AC 13 ms
9,312 KB
testcase_25 AC 7 ms
5,960 KB
testcase_26 AC 10 ms
7,784 KB
testcase_27 AC 22 ms
12,232 KB
testcase_28 WA -
testcase_29 AC 13 ms
9,392 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 746 ms
198,204 KB
testcase_35 AC 736 ms
198,988 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 737 ms
198,200 KB
testcase_39 WA -
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 2 ms
4,384 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 WA -
testcase_44 AC 1 ms
4,376 KB
testcase_45 WA -
testcase_46 AC 749 ms
198,940 KB
testcase_47 WA -
testcase_48 AC 736 ms
198,944 KB
testcase_49 WA -
testcase_50 AC 732 ms
197,856 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 724 ms
195,504 KB
testcase_54 AC 745 ms
198,956 KB
testcase_55 AC 749 ms
198,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, x; cin >> n >> x;
	vector<int>a(n);
	rep(i, n)cin >> a[i];
	vector<int>left(n), right(n);
	rep(_, 2) {
		long long sum = 0;
		int j = 0;
		for (int i = 0; i < n; ++i) {
			while (j < n && sum + a[j] <= x) {
				sum += a[j];
				j++;
			}
			left[i] = j - i;
			sum -= a[i];
		}
		reverse(all(a));
		swap(left, right);
	}
	reverse(all(right));
	// 手番の状態、勝ちなら1負けなら0を累積和で持つ
	vector dpl(n, vector<int>(n + 2, 0));
	vector dpr(n, vector<int>(n + 2, 0));
	rep2(i, 1, n + 1) {
		rep(j, n) {
			// 閉区間
			int l = j;
			int r = l + i - 1;
			if (r >= n - 1)break;
			dpl[l][i + 1] = dpl[l][i];
			dpr[r][i + 1] = dpr[r][i];
			{
				int can = min(i - 1, left[l]);
				int x = dpr[r][i] - dpr[r][i - can];
				if (x != can) {
					dpl[l][i + 1]++;
					dpr[r][i + 1]++;
					continue;
				}
			}
			int can = min(i - 1, right[r]);
			int x = dpl[l][i] - dpl[l][i - can];
			if (x != can) {
				dpl[l][i + 1]++;
				dpr[r][i + 1]++;
			}
		}
	}
	if (dpl[0][n + 1] - dpl[0][n])cout << "A" << endl;
	else cout << "B" << endl;
	return 0;
}
0