結果

問題 No.973 余興
ユーザー 👑 jupirojupiro
提出日時 2020-01-18 18:11:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,222 bytes
コンパイル時間 1,063 ms
コンパイル使用メモリ 118,592 KB
実行使用メモリ 394,800 KB
最終ジャッジ日時 2023-09-10 07:56:41
合計ジャッジ時間 69,046 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,976 ms
394,616 KB
testcase_01 WA -
testcase_02 AC 2,006 ms
394,264 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1,997 ms
394,580 KB
testcase_06 AC 2,036 ms
394,368 KB
testcase_07 AC 2,010 ms
394,112 KB
testcase_08 AC 1,992 ms
393,056 KB
testcase_09 AC 2,008 ms
394,564 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 567 ms
143,024 KB
testcase_14 WA -
testcase_15 AC 48 ms
18,880 KB
testcase_16 AC 49 ms
19,164 KB
testcase_17 WA -
testcase_18 AC 38 ms
15,688 KB
testcase_19 AC 38 ms
15,796 KB
testcase_20 AC 27 ms
12,628 KB
testcase_21 AC 48 ms
18,912 KB
testcase_22 WA -
testcase_23 AC 37 ms
15,684 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 38 ms
15,724 KB
testcase_29 WA -
testcase_30 AC 1,971 ms
394,632 KB
testcase_31 AC 1,960 ms
394,528 KB
testcase_32 AC 1,970 ms
394,536 KB
testcase_33 AC 1,927 ms
394,108 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 1,919 ms
383,988 KB
testcase_37 AC 1,916 ms
383,988 KB
testcase_38 WA -
testcase_39 AC 1,960 ms
393,512 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 2 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,930 ms
394,368 KB
testcase_48 WA -
testcase_49 AC 1,747 ms
363,640 KB
testcase_50 WA -
testcase_51 AC 1,926 ms
394,564 KB
testcase_52 AC 1,973 ms
394,568 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 (vbl[left].sum(max(left, lb[right]) + 1, right)) lose = 0;
			if (vbr[right].sum(left + 2, min(right, rb[left]) + 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