結果
問題 | No.973 余興 |
ユーザー |
![]() |
提出日時 | 2020-01-17 22:55:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
OLE
|
実行時間 | - |
コード長 | 859 bytes |
コンパイル時間 | 2,023 ms |
コンパイル使用メモリ | 174,348 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-06-25 23:32:38 |
合計ジャッジ時間 | 23,189 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | TLE * 1 OLE * 11 -- * 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;}}}for(int i=0;i<=N;i++){for(int j=i;j<=N;j++) cout<<dp[i][j]<<' '; cout<<endl;}cout<<(dp[0][N]? 'A':'B')<<endl;return 0;}