結果
| 問題 |
No.973 余興
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-01-17 23:22:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 256 ms / 4,000 ms |
| コード長 | 1,213 bytes |
| コンパイル時間 | 1,707 ms |
| コンパイル使用メモリ | 174,384 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-26 00:45:41 |
| 合計ジャッジ時間 | 6,415 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 54 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
ll x;
cin >> n >> x;
vector<ll> a(n), sum(n + 1, 0);
for (int i = 0; i < n; ++i) {
cin >> a[i];
sum[i + 1] = sum[i] + a[i];
}
vector<int> nex_row(n + 1, 0), nex_col(n + 1, 0);
for (int i = 0; i <= n; ++i) {
nex_row[i] = i + 1;
nex_col[i] = i - 1;
}
for (int d = 1; d < n; ++d) {
vector<int> tmp_row = nex_row, tmp_col = nex_col;
for (int i = 0; i <= n - d; ++i) {
if (nex_row[i] > i + d || nex_col[i + d] < i) continue;
{
int idx = lower_bound(sum.begin(), sum.begin() + i, sum[i] - x) - sum.begin();
tmp_col[i + d] = min(tmp_col[i + d], idx - 1);
}
{
int idx = upper_bound(sum.begin() + i + d, sum.end(), x + sum[i + d]) - sum.begin();
tmp_row[i] = max(tmp_row[i], idx);
}
}
nex_row = move(tmp_row);
nex_col = move(tmp_col);
}
cout << ((nex_row[0] > n || nex_col[n] < 0) ? "A" : "B") << "\n";
return 0;
}