結果
問題 | No.973 余興 |
ユーザー | HIR180 |
提出日時 | 2020-01-17 21:45:16 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,034 ms / 4,000 ms |
コード長 | 1,697 bytes |
コンパイル時間 | 2,148 ms |
コンパイル使用メモリ | 186,696 KB |
実行使用メモリ | 125,124 KB |
最終ジャッジ日時 | 2023-09-08 02:13:51 |
合計ジャッジ時間 | 27,057 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,001 ms
124,796 KB |
testcase_01 | AC | 1,034 ms
124,796 KB |
testcase_02 | AC | 979 ms
124,856 KB |
testcase_03 | AC | 995 ms
124,808 KB |
testcase_04 | AC | 988 ms
124,796 KB |
testcase_05 | AC | 985 ms
124,816 KB |
testcase_06 | AC | 971 ms
124,920 KB |
testcase_07 | AC | 1,011 ms
124,788 KB |
testcase_08 | AC | 973 ms
124,900 KB |
testcase_09 | AC | 974 ms
124,816 KB |
testcase_10 | AC | 946 ms
124,420 KB |
testcase_11 | AC | 159 ms
85,328 KB |
testcase_12 | AC | 158 ms
85,340 KB |
testcase_13 | AC | 158 ms
85,392 KB |
testcase_14 | AC | 158 ms
85,268 KB |
testcase_15 | AC | 36 ms
33,940 KB |
testcase_16 | AC | 37 ms
33,960 KB |
testcase_17 | AC | 24 ms
27,704 KB |
testcase_18 | AC | 30 ms
34,064 KB |
testcase_19 | AC | 31 ms
34,104 KB |
testcase_20 | AC | 24 ms
27,760 KB |
testcase_21 | AC | 36 ms
33,936 KB |
testcase_22 | AC | 37 ms
34,136 KB |
testcase_23 | AC | 30 ms
33,900 KB |
testcase_24 | AC | 30 ms
34,056 KB |
testcase_25 | AC | 16 ms
23,672 KB |
testcase_26 | AC | 23 ms
27,692 KB |
testcase_27 | AC | 42 ms
38,248 KB |
testcase_28 | AC | 31 ms
33,984 KB |
testcase_29 | AC | 30 ms
34,024 KB |
testcase_30 | AC | 502 ms
124,796 KB |
testcase_31 | AC | 498 ms
124,880 KB |
testcase_32 | AC | 495 ms
125,124 KB |
testcase_33 | AC | 495 ms
124,868 KB |
testcase_34 | AC | 488 ms
124,956 KB |
testcase_35 | AC | 483 ms
124,888 KB |
testcase_36 | AC | 461 ms
124,660 KB |
testcase_37 | AC | 471 ms
124,604 KB |
testcase_38 | AC | 474 ms
124,764 KB |
testcase_39 | AC | 502 ms
124,792 KB |
testcase_40 | AC | 2 ms
7,568 KB |
testcase_41 | AC | 3 ms
7,640 KB |
testcase_42 | AC | 2 ms
7,528 KB |
testcase_43 | AC | 2 ms
9,608 KB |
testcase_44 | AC | 2 ms
7,540 KB |
testcase_45 | AC | 4 ms
12,268 KB |
testcase_46 | AC | 483 ms
125,108 KB |
testcase_47 | AC | 486 ms
124,972 KB |
testcase_48 | AC | 493 ms
124,804 KB |
testcase_49 | AC | 468 ms
124,204 KB |
testcase_50 | AC | 495 ms
124,796 KB |
testcase_51 | AC | 495 ms
124,876 KB |
testcase_52 | AC | 504 ms
124,904 KB |
testcase_53 | AC | 483 ms
124,684 KB |
testcase_54 | AC | 484 ms
124,788 KB |
testcase_55 | AC | 498 ms
124,784 KB |
ソースコード
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; typedef long long ll; typedef pair<int,int> P; typedef pair<int,P> P1; typedef pair<P,P> P2; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define mod 1000000007 #define fi first #define sc second #define rep(i,x) for(int i=0;i<x;i++) #define repn(i,x) for(int i=1;i<=x;i++) #define SORT(x) sort(x.begin(),x.end()) #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end()) #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) int n,x,a[5005]; struct BIT { short bit[5005]; void add(int i,short x) { for(int s=i;s<5005;s+=s&-s) bit[s]+=x; } short sum(int i) { short res=0; for(int s=i;s>0;s-=s&-s) res+=bit[s]; return res; } }bitL[5005],bitR[5005]; bool dp[5005][5005]; int goL[5005],goR[5005]; int main(){ scanf("%d%d",&n,&x); repn(i,n) scanf("%d",&a[i]); repn(i,n){ goL[i] = n; ll sum = 0; for(int j=i;j<=n;j++){ sum += a[j]; if(sum > x){ goL[i] = j-1; break; } } goR[i] = 1; sum = 0; for(int j=i;j>=0;j--){ sum += a[j]; if(sum > x){ goR[i] = j+1; break; } } } for(int len=1;len<=n;len++){ for(int i=1;i+len-1<=n;i++){ int L = i, R = i+len-1; int x = min(goL[L],R-1); if(L <= x){ if(bitR[R].sum(x+1) > bitR[R].sum(L)){ dp[L][R] = 1; goto nxt; } } x = max(goR[R],L+1); if(x <= R){ if(bitL[L].sum(R-1) > bitL[L].sum(x-2)){ dp[L][R] = 1; goto nxt; } } bitL[L].add(R,1); bitR[R].add(L,1); nxt:; } } puts(dp[1][n]?"A":"B"); }