結果
問題 | No.973 余興 |
ユーザー | drken1215 |
提出日時 | 2020-01-18 20:29:36 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,300 ms / 4,000 ms |
コード長 | 3,346 bytes |
コンパイル時間 | 813 ms |
コンパイル使用メモリ | 81,160 KB |
実行使用メモリ | 199,552 KB |
最終ジャッジ日時 | 2024-06-28 02:53:58 |
合計ジャッジ時間 | 61,770 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,682 ms
199,552 KB |
testcase_01 | AC | 1,650 ms
199,552 KB |
testcase_02 | AC | 1,613 ms
199,424 KB |
testcase_03 | AC | 1,593 ms
199,424 KB |
testcase_04 | AC | 1,645 ms
199,552 KB |
testcase_05 | AC | 1,700 ms
199,552 KB |
testcase_06 | AC | 1,683 ms
199,424 KB |
testcase_07 | AC | 1,670 ms
199,424 KB |
testcase_08 | AC | 1,681 ms
198,784 KB |
testcase_09 | AC | 1,671 ms
199,552 KB |
testcase_10 | AC | 1,609 ms
191,872 KB |
testcase_11 | AC | 566 ms
74,112 KB |
testcase_12 | AC | 544 ms
74,112 KB |
testcase_13 | AC | 566 ms
73,472 KB |
testcase_14 | AC | 557 ms
73,472 KB |
testcase_15 | AC | 43 ms
11,264 KB |
testcase_16 | AC | 45 ms
11,392 KB |
testcase_17 | AC | 26 ms
8,320 KB |
testcase_18 | AC | 34 ms
9,728 KB |
testcase_19 | AC | 34 ms
9,728 KB |
testcase_20 | AC | 26 ms
8,064 KB |
testcase_21 | AC | 44 ms
11,264 KB |
testcase_22 | AC | 43 ms
11,264 KB |
testcase_23 | AC | 34 ms
9,856 KB |
testcase_24 | AC | 34 ms
9,600 KB |
testcase_25 | AC | 16 ms
6,272 KB |
testcase_26 | AC | 26 ms
8,192 KB |
testcase_27 | AC | 54 ms
12,544 KB |
testcase_28 | AC | 34 ms
9,728 KB |
testcase_29 | AC | 34 ms
9,600 KB |
testcase_30 | AC | 1,896 ms
199,552 KB |
testcase_31 | AC | 1,838 ms
199,552 KB |
testcase_32 | AC | 1,825 ms
199,552 KB |
testcase_33 | AC | 1,847 ms
199,424 KB |
testcase_34 | AC | 1,810 ms
198,784 KB |
testcase_35 | AC | 1,797 ms
199,552 KB |
testcase_36 | AC | 1,761 ms
194,432 KB |
testcase_37 | AC | 1,751 ms
194,432 KB |
testcase_38 | AC | 1,843 ms
198,912 KB |
testcase_39 | AC | 1,823 ms
199,168 KB |
testcase_40 | AC | 2 ms
5,376 KB |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | AC | 2 ms
5,376 KB |
testcase_43 | AC | 2 ms
5,376 KB |
testcase_44 | AC | 2 ms
5,376 KB |
testcase_45 | AC | 2 ms
5,376 KB |
testcase_46 | AC | 1,793 ms
199,424 KB |
testcase_47 | AC | 1,797 ms
199,424 KB |
testcase_48 | AC | 1,810 ms
199,424 KB |
testcase_49 | AC | 1,664 ms
184,192 KB |
testcase_50 | AC | 2,300 ms
198,144 KB |
testcase_51 | AC | 1,807 ms
199,552 KB |
testcase_52 | AC | 1,821 ms
199,552 KB |
testcase_53 | AC | 1,962 ms
196,096 KB |
testcase_54 | AC | 1,834 ms
199,552 KB |
testcase_55 | AC | 1,862 ms
199,424 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) { return s << '<' << P.first << ", " << P.second << '>'; } template<class T> ostream& operator << (ostream &s, vector<T> P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) { for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; } template <class Abel> struct BIT { const Abel UNITY_SUM = 0; // to be set vector<Abel> dat; /* [1, n] */ BIT(int n) : dat(n + 1, UNITY_SUM) { } void init(int n) { dat.assign(n + 1, UNITY_SUM); } /* a is 1-indexed */ inline void add(int a, Abel x) { for (int i = a; i < (int)dat.size(); i += i & -i) dat[i] = dat[i] + x; } /* [1, a], a is 1-indexed */ inline Abel sum(int a) { Abel res = UNITY_SUM; for (int i = a; i > 0; i -= i & -i) res = res + dat[i]; return res; } /* [a, b), a and b are 1-indexed */ inline Abel sum(int a, int b) { return sum(b - 1) - sum(a - 1); } /* debug */ void print() { for (int i = 1; i < (int)dat.size(); ++i) cout << sum(i, i + 1) << ","; cout << endl; } }; int N; long long X; vector<long long> a, s; vector<int> l2r, r2l; bool solve() { l2r.assign(N+1, -1), r2l.assign(N+1, -1); int r = 0; for (int l = 0; l < N; ++l) { while (r < N && s[r + 1] - s[l] <= X) { ++r; r2l[r] = l; } l2r[l] = r; } //COUT(l2r); COUT(r2l); vector<BIT<int> > left(N+5, BIT<int>(N+5)); vector<BIT<int> > right(N+5, BIT<int>(N+5)); for (int l = 0; l <= N; ++l) left[l].add(l+1, 1); for (int r = 0; r <= N; ++r) right[r].add(r+1, 1); for (int bet = 1; bet <= N; ++bet) { for (int l = 0; l+bet <= N; ++l) { int r = l+bet; // l+1, ..., min(l2r[l], r) に「負け」があれば OK int mi = min(l2r[l], r); int tmp1 = (mi-l) - right[r].sum(l+2, mi+2); // max(l, r2l[r]), ..., r-1 に「負け」があれば OK int ma = max(l, r2l[r]); int tmp2 = (r-ma) - left[l].sum(ma+1, r+1); // judge if (tmp1 + tmp2) left[l].add(r+1, 1), right[r].add(l+1, 1); //cout << l << ", " << r << ": " << (left[l].sum(r+1, r+2) ? "win" : "lose") << endl; } } /* for (int l = 0; l <= N; ++l) { COUT(l); cout << "sente: "; sente[l].print(); cout << "gote: "; gote[l].print(); } */ return left[0].sum(N+1, N+2); } int main() { while (cin >> N >> X) { a.resize(N); s.assign(N+1, 0); for (int i = 0; i < N; ++i) cin >> a[i], s[i+1] = s[i] + a[i]; if (solve()) cout << "A" << endl; else cout << "B" << endl; } }