結果
| 問題 |
No.973 余興
|
| コンテスト | |
| ユーザー |
tekihei2317
|
| 提出日時 | 2020-01-17 22:56:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 767 bytes |
| コンパイル時間 | 1,580 ms |
| コンパイル使用メモリ | 173,320 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-06-25 23:33:53 |
| 合計ジャッジ時間 | 11,474 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | AC * 11 TLE * 1 -- * 42 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Lint=long long;
int main()
{
int N,X; cin>>N>>X;
vector<int> a(N);
for(int i=0;i<N;i++) cin>>a[i];
vector<vector<bool>> dp(N+1,vector<bool>(N+1));
for(int i=0;i<=N;i++) dp[i][i]=true;
for(int len=1;len<=N;len++){
for(int l=0;l+len<=N;l++){
int r=l+len;
Lint sum=0;
for(int i=l;i<r;i++){
sum+=a[i]; if(sum>X) break;
// dp[l][r]|=!dp[i+1][r];
if(!dp[i+1][r]) dp[l][r]=true;
}
sum=0;
for(int i=r-1;i>=l;i--){
sum+=a[i]; if(sum>X) break;
// dp[l][r]|=!dp[l][i];
if(!dp[l][i]) dp[l][r]=true;
}
}
}
cout<<(dp[0][N]? 'A':'B')<<endl;
return 0;
}
tekihei2317