結果
問題 | No.973 余興 |
ユーザー | mugen_1337 |
提出日時 | 2021-04-14 17:21:59 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 891 ms / 4,000 ms |
コード長 | 2,463 bytes |
コンパイル時間 | 3,030 ms |
コンパイル使用メモリ | 205,404 KB |
実行使用メモリ | 198,996 KB |
最終ジャッジ日時 | 2023-09-13 06:54:29 |
合計ジャッジ時間 | 30,185 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 710 ms
198,996 KB |
testcase_01 | AC | 708 ms
198,932 KB |
testcase_02 | AC | 705 ms
198,928 KB |
testcase_03 | AC | 708 ms
198,912 KB |
testcase_04 | AC | 713 ms
198,872 KB |
testcase_05 | AC | 722 ms
198,860 KB |
testcase_06 | AC | 709 ms
198,864 KB |
testcase_07 | AC | 713 ms
198,924 KB |
testcase_08 | AC | 699 ms
198,136 KB |
testcase_09 | AC | 708 ms
198,924 KB |
testcase_10 | AC | 677 ms
191,336 KB |
testcase_11 | AC | 239 ms
73,944 KB |
testcase_12 | AC | 252 ms
73,776 KB |
testcase_13 | AC | 239 ms
73,256 KB |
testcase_14 | AC | 238 ms
73,204 KB |
testcase_15 | AC | 19 ms
10,864 KB |
testcase_16 | AC | 18 ms
11,384 KB |
testcase_17 | AC | 10 ms
8,124 KB |
testcase_18 | AC | 13 ms
9,364 KB |
testcase_19 | AC | 13 ms
9,312 KB |
testcase_20 | AC | 10 ms
7,848 KB |
testcase_21 | AC | 18 ms
10,964 KB |
testcase_22 | AC | 18 ms
10,964 KB |
testcase_23 | AC | 14 ms
9,312 KB |
testcase_24 | AC | 13 ms
9,444 KB |
testcase_25 | AC | 7 ms
5,960 KB |
testcase_26 | AC | 10 ms
7,728 KB |
testcase_27 | AC | 22 ms
12,284 KB |
testcase_28 | AC | 14 ms
9,308 KB |
testcase_29 | AC | 13 ms
9,312 KB |
testcase_30 | AC | 832 ms
198,924 KB |
testcase_31 | AC | 833 ms
198,940 KB |
testcase_32 | AC | 837 ms
198,868 KB |
testcase_33 | AC | 848 ms
198,936 KB |
testcase_34 | AC | 865 ms
198,088 KB |
testcase_35 | AC | 877 ms
198,868 KB |
testcase_36 | AC | 834 ms
193,908 KB |
testcase_37 | AC | 836 ms
193,932 KB |
testcase_38 | AC | 871 ms
198,396 KB |
testcase_39 | AC | 891 ms
198,732 KB |
testcase_40 | AC | 1 ms
4,376 KB |
testcase_41 | AC | 2 ms
4,380 KB |
testcase_42 | AC | 1 ms
4,380 KB |
testcase_43 | AC | 1 ms
4,380 KB |
testcase_44 | AC | 1 ms
4,376 KB |
testcase_45 | AC | 2 ms
4,380 KB |
testcase_46 | AC | 688 ms
198,868 KB |
testcase_47 | AC | 690 ms
198,984 KB |
testcase_48 | AC | 686 ms
198,924 KB |
testcase_49 | AC | 613 ms
183,680 KB |
testcase_50 | AC | 672 ms
197,612 KB |
testcase_51 | AC | 681 ms
198,928 KB |
testcase_52 | AC | 873 ms
198,840 KB |
testcase_53 | AC | 853 ms
195,648 KB |
testcase_54 | AC | 872 ms
198,928 KB |
testcase_55 | AC | 859 ms
198,996 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; #define ALL(x) begin(x),end(x) #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; #define mod 998244353 using ll=long long; const int INF=1000000000; const ll LINF=1001002003004005006ll; int dx[]={1,0,-1,0},dy[]={0,1,0,-1}; template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;} template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;} struct IOSetup{ IOSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(12); } } iosetup; template<typename T> ostream &operator<<(ostream &os,const vector<T>&v){ for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" "); return os; } template<typename T> istream &operator>>(istream &is,vector<T>&v){ for(T &x:v)is>>x; return is; } signed main(){ int n;ll x;cin>>n>>x; vector<ll> v(n); cin>>v; vector<int> t_l(n),t_r(n);// can take [i, t_l[i]], [t_r[i], i] vector<ll> s(n); s[0]=v[0]; for(int i=1;i<n;i++) s[i]=s[i-1]+v[i]; for(int i=0;i<n;i++){ { ll sum=0; int j; for(j=i;j<n;j++){ sum+=v[j]; if(sum>x) break; } t_l[i]=j-1; } { ll sum=0; int j; for(j=i;j>=0;j--){ sum+=v[j]; if(sum>x) break; } t_r[i]=j+1; } } vector<vector<int>> L(n+2,vector<int>(n+2,0)),R(n+2,vector<int>(n+2,0)); rep(i,n) L[i][i]=1,R[i][i]=1; auto getL=[&](int R,int l,int r){ int ret=L[l][R]; if(r+1<=n) ret-=L[r+1][R]; return ret; }; auto getR=[&](int L,int l,int r){ int ret=R[L][r]; if(l) ret-=R[L][l-1]; return ret; }; bool res=false; for(int w=2;w<=n;w++){ for(int l=0;l+w<=n;l++){ int r=l+w-1; bool win=false; int a=t_l[l];// can eat [l,a] int b=t_r[r];// [b,r] if(getL(r,l+1,a+1)) win=true; if(getR(l,b-1,r-1)) win=true; L[l][r]=L[l+1][r]; R[l][r]=R[l][r-1]; if(!win){ L[l][r]++; R[l][r]++; } if(l==0 and r==n-1) res=win; } } cout<<("BA"[res])<<endl; return 0; }