結果

問題 No.973 余興
ユーザー 👑 jupirojupiro
提出日時 2020-01-18 17:35:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,224 bytes
コンパイル時間 1,325 ms
コンパイル使用メモリ 117,904 KB
実行使用メモリ 394,804 KB
最終ジャッジ日時 2023-09-10 06:22:08
合計ジャッジ時間 70,504 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,136 ms
394,656 KB
testcase_01 WA -
testcase_02 AC 2,065 ms
394,284 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2,095 ms
394,656 KB
testcase_06 AC 2,053 ms
394,324 KB
testcase_07 AC 2,051 ms
394,028 KB
testcase_08 AC 2,039 ms
393,072 KB
testcase_09 AC 2,045 ms
394,660 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 557 ms
142,952 KB
testcase_14 WA -
testcase_15 AC 42 ms
18,980 KB
testcase_16 AC 45 ms
19,176 KB
testcase_17 WA -
testcase_18 AC 35 ms
15,648 KB
testcase_19 AC 35 ms
15,756 KB
testcase_20 AC 26 ms
12,592 KB
testcase_21 AC 44 ms
18,916 KB
testcase_22 WA -
testcase_23 AC 36 ms
15,724 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 36 ms
15,816 KB
testcase_29 WA -
testcase_30 AC 1,979 ms
394,600 KB
testcase_31 AC 1,923 ms
394,544 KB
testcase_32 AC 1,942 ms
394,652 KB
testcase_33 AC 1,890 ms
394,016 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 1,854 ms
383,940 KB
testcase_37 AC 1,859 ms
383,996 KB
testcase_38 WA -
testcase_39 AC 1,906 ms
393,496 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 2 ms
4,380 KB
testcase_46 WA -
testcase_47 AC 1,871 ms
394,292 KB
testcase_48 WA -
testcase_49 AC 1,739 ms
363,764 KB
testcase_50 WA -
testcase_51 AC 1,941 ms
394,652 KB
testcase_52 AC 1,911 ms
394,584 KB
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

class BIT {
private:
	ll N;
	vector<ll> node;
public:
	BIT(ll M) {
		node = vector<ll>(M + 1, 0);
		N = M;
	}

	ll sum(ll i) {
		ll s = 0;
		while (i > 0) {
			s += node[i];
			i -= i & -i;
		}
		return s;
	}

	ll sum(ll i, ll j) {
		ll l = sum(i - 1);
		ll r = sum(j);
		return r - l;
	}

	void add(ll i, ll x) {
		while (i <= N) {
			node[i] += x;
			i += i & -i;
		}
	}
};


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	ll N, X; scanf("%lld %lld", &N, &X);
	vector<ll> a(N); for (ll i = 0; i < N; i++) scanf("%lld", &a[i]);
	vector<ll> rb(N);
	vector<ll> lb(N);
	for (ll i = 0; i < N; i++) {
		ll j = i;
		ll sum = 0;
		while (j < N && sum + a[j] <= X) {
			rb[i] = j;
			sum += a[j];
			j++;
		}
	}
	for (ll i = N - 1; i >= 0; i--) {
		ll j = i;
		ll sum = 0;
		while (j >= 0 && sum + a[j] <= X) {
			lb[i] = j;
			sum += a[j];
			j--;
		}
	}

	vector<BIT> vbl(N, BIT(N + 1)), vbr(N, BIT(N + 1));
	for (ll len = 1; len <= N; len++) {
		for (ll left = 0; left + len - 1 < N; left++) {
			ll right = left + len - 1;
			ll lose = 1;
			//cout << right << endl;
			if (vbr[right].sum(min(right + 1, rb[left] + 1))) lose = 0;
			if (vbl[left].sum(max(left + 1, lb[right] + 1), right + 1)) lose = 0;
			if (lose) {
				vbl[left].add(right + 1, 1);
				vbr[right].add(left + 1, 1);
			}
		}
	}
	if (vbl[0].sum(N,N)) puts("B");
	else puts("A");
	return 0;
}
0