結果
| 問題 |
No.973 余興
|
| コンテスト | |
| ユーザー |
emthrm
|
| 提出日時 | 2020-01-18 05:59:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,278 bytes |
| コンパイル時間 | 2,734 ms |
| コンパイル使用メモリ | 199,300 KB |
| 最終ジャッジ日時 | 2025-01-08 19:51:34 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 46 WA * 8 |
ソースコード
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
IOSetup() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(20);
}
} iosetup;
int main() {
int n, x; cin >> n >> x;
if (n == 1) {
cout << "B\n";
return 0;
}
vector<int> a(n); REP(i, n) cin >> a[i];
vector<int> l(n, 0), r(n, 0);
REP(i, n) {
int sum = a[i], j = i + 1;
while (j < n && sum + a[j] <= x) ++j;
l[i] = j - i;
}
REP(i, n) {
int sum = a[i], j = i - 1;
while (j >= 0 && sum + a[j] <= x) --j;
r[i] = i - j;
}
vector<vector<int> > dp_l(n, vector<int>(n, 0)), dp_r(n, vector<int>(n, 0));
FOR(len, 2, n + 1) {
REP(i, n) {
int j = i + len - 1;
if (j >= n) break;
int chou = min(len - 1, l[i]);
if (dp_r[i + 1][j] - (i + chou + 1 >= n ? 0 : dp_r[i + chou + 1][j]) != chou) {
dp_l[i][j] = dp_l[i][j - 1] + 1;
dp_r[i][j] = dp_r[i + 1][j] + 1;
continue;
}
chou = min(len - 1, r[j]);
if (dp_l[i][j - 1] - (j - chou - 1 < 0 ? 0 : dp_l[i][j - chou - 1]) != chou) {
dp_l[i][j] = dp_l[i][j - 1] + 1;
dp_r[i][j] = dp_r[i + 1][j] + 1;
continue;
}
dp_l[i][j] = dp_l[i][j - 1];
dp_r[i][j] = dp_r[i + 1][j];
}
}
// REP(i, n) REP(j, n) cout << i << ' ' << j << " : " << dp_l[i][j] << '\n';
cout << (dp_l[0][n - 1] - dp_l[0][n - 2] == 1 ? "A\n" : "B\n");
return 0;
}
emthrm