結果
問題 | No.973 余興 |
ユーザー |
|
提出日時 | 2020-01-17 22:08:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,157 bytes |
コンパイル時間 | 1,645 ms |
コンパイル使用メモリ | 174,156 KB |
実行使用メモリ | 297,088 KB |
最終ジャッジ日時 | 2024-06-25 20:41:04 |
合計ジャッジ時間 | 85,025 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 WA * 26 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;#define rep(i, n) for (int i = 0; i < (n); i++)#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)#define range(a) a.begin(), a.end()int main() {int N; cin >> N;ll X; cin >> X;vector<ll> A(N); rep(i, N) cin >> A[i];vector<ll> S(N + 1); rep(i, N) S[i + 1] = S[i] + A[i];vector<ll> R(N + 1); repr(i, N) R[i] = R[i + 1] + A[i];vector<vector<int>> dp(N, vector<int>(N));vector<vector<int>> eplr(N, vector<int>(N));vector<vector<int>> eprl(N, vector<int>(N));for (int d = 1; d <= N - 1; d++) {for (int l = 0; l + d <= N - 1; l++) {int r = l + d;eplr[l][r] = dp[l][l] + eplr[l + 1][r];eprl[r][l] = dp[r][r] + eprl[r - 1][l];// dpl[l][l+1]...dpl[l][l+x] -> 0// dpr[r][r]...dpr[r][r-y] -> 0int x = upper_bound(range(S), X + S[l]) - S.begin() - 1;int y = R.rend() - upper_bound(R.rbegin(), R.rend(), X + R[r + 1]) + 1;if (eplr[l][x] != x - l + 1) {dp[l][r] = 1;}if (eprl[r][y] != r - y + 1) {dp[l][r] = 1;}}}cout << (dp[0][N - 1] ? "A" : "B") << endl;}