結果
問題 | No.973 余興 |
ユーザー | utouto97 |
提出日時 | 2020-01-19 17:16:24 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,550 bytes |
コンパイル時間 | 3,516 ms |
コンパイル使用メモリ | 149,712 KB |
実行使用メモリ | 198,948 KB |
最終ジャッジ日時 | 2023-09-15 20:21:50 |
合計ジャッジ時間 | 12,984 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 209 ms
198,644 KB |
testcase_01 | AC | 208 ms
198,644 KB |
testcase_02 | AC | 207 ms
198,708 KB |
testcase_03 | AC | 207 ms
198,840 KB |
testcase_04 | AC | 207 ms
198,728 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 200 ms
191,060 KB |
testcase_11 | AC | 78 ms
73,748 KB |
testcase_12 | AC | 79 ms
73,580 KB |
testcase_13 | WA | - |
testcase_14 | AC | 78 ms
73,044 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 7 ms
8,080 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 11 ms
10,924 KB |
testcase_23 | AC | 9 ms
9,312 KB |
testcase_24 | AC | 9 ms
9,388 KB |
testcase_25 | AC | 5 ms
5,932 KB |
testcase_26 | AC | 7 ms
7,992 KB |
testcase_27 | AC | 12 ms
12,288 KB |
testcase_28 | WA | - |
testcase_29 | AC | 9 ms
9,396 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 213 ms
197,848 KB |
testcase_35 | AC | 210 ms
198,784 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 211 ms
198,200 KB |
testcase_39 | WA | - |
testcase_40 | AC | 2 ms
4,380 KB |
testcase_41 | AC | 2 ms
4,376 KB |
testcase_42 | AC | 2 ms
4,380 KB |
testcase_43 | WA | - |
testcase_44 | AC | 2 ms
4,380 KB |
testcase_45 | WA | - |
testcase_46 | AC | 211 ms
198,652 KB |
testcase_47 | WA | - |
testcase_48 | AC | 209 ms
198,632 KB |
testcase_49 | WA | - |
testcase_50 | AC | 208 ms
197,444 KB |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | AC | 205 ms
195,208 KB |
testcase_54 | AC | 208 ms
198,732 KB |
testcase_55 | AC | 208 ms
198,720 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++) #define all(x) (x).begin(),(x).end() #define sz(x) ((int)x.size()) template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;} template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;} /* */ using vi = vector<int>; using vvi = vector<vi>; using P = pair<int,int>; signed main() { int n, x; cin >> n >> x; vi a(n); rep(i, 0, n) cin >> a[i]; vi lr(n), rl(n); { int r = 0, sum = 0; rep(l, 0, n){ while(r < n and sum + a[r] <= x){ sum += a[r]; r++; } lr[l] = r-1; if(l == r) r++; else sum -= a[l]; } } { int l = n-1, sum = 0; for(int r = n-1; r >= 0; r--){ while(l >= 0 and sum + a[l] <= x){ sum += a[l]; l--; } rl[r] = l+1; if(l == r) l--; else sum -= a[r]; } } vvi dp(n+1, vi(n, 1)); // dp[len][left] rep(len, 2, n+1){ vi sdp(n+1); rep(i, 0, n) sdp[i+1] = sdp[i] + dp[len-1][i]; rep(left, 0, n){ if(left+len-1 >= n) break; int l = left, r = left+len-1; int s = lr[l], t = rl[r]; if(sdp[s+1]-sdp[l] > 0){ dp[len][left] = 0; } if(sdp[r+1]-sdp[t] > 0){ dp[len][left] = 0; } } } // rep(len, 0, n+1) { // rep(left, 0, n) { // cout << dp[len][left] << " "; // } // cout << endl; // } if(dp[n][0]) cout << "B" << endl; else cout << "A" << endl; return 0; }