結果
問題 | No.973 余興 |
ユーザー | beet |
提出日時 | 2020-01-17 21:53:08 |
言語 | C++17 (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,121 bytes |
コンパイル時間 | 2,108 ms |
コンパイル使用メモリ | 204,744 KB |
実行使用メモリ | 266,252 KB |
最終ジャッジ日時 | 2023-09-08 02:36:47 |
合計ジャッジ時間 | 55,854 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,903 ms
266,060 KB |
testcase_01 | WA | - |
testcase_02 | AC | 1,842 ms
265,764 KB |
testcase_03 | AC | 1,831 ms
265,904 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 1,901 ms
265,852 KB |
testcase_07 | WA | - |
testcase_08 | AC | 1,963 ms
264,932 KB |
testcase_09 | AC | 1,870 ms
266,252 KB |
testcase_10 | AC | 1,765 ms
256,396 KB |
testcase_11 | WA | - |
testcase_12 | AC | 443 ms
103,336 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 44 ms
17,328 KB |
testcase_16 | AC | 46 ms
17,732 KB |
testcase_17 | AC | 28 ms
12,660 KB |
testcase_18 | AC | 37 ms
14,880 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 46 ms
17,472 KB |
testcase_22 | AC | 46 ms
17,152 KB |
testcase_23 | AC | 36 ms
14,952 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 59 ms
19,008 KB |
testcase_28 | AC | 38 ms
15,152 KB |
testcase_29 | WA | - |
testcase_30 | AC | 1,341 ms
266,000 KB |
testcase_31 | AC | 1,315 ms
266,108 KB |
testcase_32 | AC | 1,311 ms
266,000 KB |
testcase_33 | AC | 1,321 ms
265,780 KB |
testcase_34 | AC | 1,354 ms
264,768 KB |
testcase_35 | WA | - |
testcase_36 | AC | 1,329 ms
259,560 KB |
testcase_37 | AC | 1,353 ms
259,720 KB |
testcase_38 | AC | 1,306 ms
265,512 KB |
testcase_39 | WA | - |
testcase_40 | AC | 2 ms
4,376 KB |
testcase_41 | AC | 1 ms
4,376 KB |
testcase_42 | AC | 1 ms
4,380 KB |
testcase_43 | AC | 1 ms
4,380 KB |
testcase_44 | AC | 2 ms
4,380 KB |
testcase_45 | AC | 3 ms
4,380 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | AC | 1,333 ms
265,952 KB |
testcase_49 | AC | 1,223 ms
246,648 KB |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | AC | 1,333 ms
261,632 KB |
testcase_54 | WA | - |
testcase_55 | WA | - |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} template<typename T> struct BIT{ int n; vector<T> bit; //1-indexed BIT(int n_):n(n_+1),bit(n+1,0){} T sum(int i){ T s(0); for(int x=i;x>0;x-=(x&-x)) s+=bit[x]; return s; } void add(int i,T a){ if(i==0) return; for(int x=i;x<=n;x+=(x&-x)) bit[x]+=a; } int lower_bound(int w){ if(w<=0) return 0; int x=0,r=1; while(r<n) r<<=1; for(int k=r;k>0;k>>=1){ if(x+k<=n&&bit[x+k]<w){ w-=bit[x+k]; x+=k; } } return x+1; } // [l, r) T query(int l,int r){ return sum(r-1)-sum(l-1); } T sum0(int i){ return sum(i+1); } void add0(int i,T a){ add(i+1,a); } T query0(int l,int r){ return sum(r)-sum(l); } }; //INSERT ABOVE HERE const int MAX = 5050; int dp[MAX][MAX]={}; signed main(){ int n,x; cin>>n>>x; vector<int> as(n); for(int i=0;i<n;i++) cin>>as[i]; //vector<int> sm(n+1,0); //for(int i=0;i<n;i++) sm[i+1]=sm[i]+as[i]; vector<int> ls(n),rs(n); for(int i=0;i<n;i++){ { int j=i-1; long long sm=0; while(j>=0&&sm+as[j]<=x){ sm+=as[j]; j--; } ls[i]=j+1; } { int j=i+1; long long sm=0; while(j<n&&sm+as[j]<=x){ sm+=as[j]; j++; } rs[i]=j-1; } // cout<<i<<":"<<ls[i]<<" "<<rs[i]<<endl; } using B = BIT<int>; vector<B> bl(n,B(n+1)); vector<B> br(n,B(n+1)); for(int w=1;w<=n;w++){ for(int l=0;l+w<=n;l++){ // [l, r] int r=l+w-1; dp[l][r]|=bl[l].sum0(r); dp[l][r]|=br[r].sum0(l); if(dp[l][r]) continue; // cout<<l<<" "<<r<<endl; if(r+1<n){ bl[l].add0(r+1,1); bl[l].add0(rs[r]+1,-1); } // cout<<l<<" "<<r<<endl; if(l>0){ br[r].add0(l-1,-1); br[r].add0(ls[l],1); } } } cout<<(dp[0][n-1]?"A":"B")<<endl; return 0; }