結果
| 問題 |
No.973 余興
|
| コンテスト | |
| ユーザー |
totori_nyaa
|
| 提出日時 | 2020-01-18 04:39:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,071 bytes |
| コンパイル時間 | 2,101 ms |
| コンパイル使用メモリ | 174,904 KB |
| 実行使用メモリ | 814,720 KB |
| 最終ジャッジ日時 | 2024-06-26 08:48:58 |
| 合計ジャッジ時間 | 9,059 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | MLE * 1 -- * 53 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
set<int> st[5000],ts[5000];
bool dp[5000][5000];
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
int n,x;
cin>>n>>x;
ll a[n];
ll sum[n+1]={};
for(int i=0;i<n;i++){
cin>>a[i];
sum[i+1] += a[i] + sum[i];
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
st[i].insert(j);
ts[i].insert(j);
}
}
for(int i=n-1;i>=0;i--){
for(int j=i+1;j<n;j++){
int ret = *st[i].upper_bound(i);
ll dif = sum[ret] - sum[i];
bool pos = false;
if(dif <= x) pos = 1;
auto itr = ts[j].lower_bound(j);
itr--;
dif = sum[j+1] - sum[*itr];
if(dif <= x) pos = 1;
if(pos){
dp[i][j] = 1;
ts[j].erase(i);
st[i].erase(j);
}
}
}
if(dp[0][n-1]){
cout << "A\n";
}
else cout << "B\n";
}
totori_nyaa