結果

問題 No.973 余興
ユーザー minato
提出日時 2020-01-17 22:13:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 1,476 bytes
コンパイル時間 2,296 ms
コンパイル使用メモリ 184,644 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-25 20:48:32
合計ジャッジ時間 40,612 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31 WA * 18 RE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,X; cin >> N >> X;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    vector<ll> ls(N+1),rs(N+1);
    rep(i,N) ls[i+1] = ls[i] + A[i];
    for (int i = N; i > 0; i--) rs[i-1] = rs[i] + A[i];
    reverse(all(rs));
    vector<vector<bool>> dp(N, vector<bool>(N));
    for (int k = 1; k < N; k++) {
        for (int i = 0; i+k < N; i++) {
            int p = upper_bound(all(ls),X+ls[i]) - ls.begin();
            if (p > i+k) dp[i][i+k] = true;
            if (!dp[p-1][i+k]) dp[i][i+k] = true;
            int q = upper_bound(all(rs),X+rs[N-i-k+1]) - rs.begin();
            if (q > N-i) dp[i][i+k] = true;
            if (!dp[i][N-q+1]) dp[i][i+k] = true;
        }
    }

    cout << (dp[0][N-1] ? "A" : "B") << endl;
}
0