結果

問題 No.973 余興
ユーザー 👑 jupirojupiro
提出日時 2020-01-18 16:08:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,263 bytes
コンパイル時間 2,794 ms
コンパイル使用メモリ 117,412 KB
実行使用メモリ 394,780 KB
最終ジャッジ日時 2023-09-09 23:24:56
合計ジャッジ時間 50,776 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,198 ms
394,528 KB
testcase_01 AC 1,203 ms
394,672 KB
testcase_02 AC 1,206 ms
394,312 KB
testcase_03 AC 1,218 ms
394,012 KB
testcase_04 AC 1,192 ms
394,524 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1,105 ms
378,964 KB
testcase_11 AC 489 ms
144,080 KB
testcase_12 AC 484 ms
144,084 KB
testcase_13 WA -
testcase_14 AC 480 ms
142,880 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 18 ms
12,868 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 29 ms
18,964 KB
testcase_23 AC 23 ms
15,740 KB
testcase_24 AC 23 ms
15,684 KB
testcase_25 AC 11 ms
8,520 KB
testcase_26 AC 17 ms
12,532 KB
testcase_27 AC 34 ms
21,584 KB
testcase_28 WA -
testcase_29 AC 23 ms
15,516 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 1,591 ms
392,784 KB
testcase_35 AC 1,480 ms
394,780 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1,500 ms
393,204 KB
testcase_39 WA -
testcase_40 AC 1 ms
4,380 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 1 ms
4,380 KB
testcase_45 WA -
testcase_46 AC 1,498 ms
394,564 KB
testcase_47 WA -
testcase_48 AC 1,508 ms
394,524 KB
testcase_49 WA -
testcase_50 AC 1,489 ms
391,384 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 1,428 ms
387,684 KB
testcase_54 AC 1,446 ms
394,564 KB
testcase_55 AC 1,493 ms
394,340 KB
権限があれば一括ダウンロードができます

ソースコード

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 (vbl[left].sum(min(right + 1, rb[left] + 1))) lose = 0;
			if (vbr[right].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(rb[0] + 1) || vbr[N-1].sum(lb[N - 1] + 1,N)) puts("A");
	else puts("B");
	return 0;
}
0