結果
問題 | No.973 余興 |
ユーザー | Enjapma_kyopro |
提出日時 | 2020-01-18 12:31:13 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,440 ms / 4,000 ms |
コード長 | 4,738 bytes |
コンパイル時間 | 2,024 ms |
コンパイル使用メモリ | 170,652 KB |
実行使用メモリ | 370,328 KB |
最終ジャッジ日時 | 2023-09-09 13:11:19 |
合計ジャッジ時間 | 47,698 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,429 ms
360,444 KB |
testcase_01 | AC | 1,419 ms
360,768 KB |
testcase_02 | AC | 1,431 ms
360,684 KB |
testcase_03 | AC | 1,432 ms
360,792 KB |
testcase_04 | AC | 1,425 ms
360,940 KB |
testcase_05 | AC | 1,408 ms
360,884 KB |
testcase_06 | AC | 1,415 ms
360,872 KB |
testcase_07 | AC | 1,440 ms
360,752 KB |
testcase_08 | AC | 1,426 ms
359,940 KB |
testcase_09 | AC | 1,416 ms
360,948 KB |
testcase_10 | AC | 1,352 ms
349,960 KB |
testcase_11 | AC | 341 ms
186,988 KB |
testcase_12 | AC | 338 ms
191,812 KB |
testcase_13 | AC | 339 ms
195,264 KB |
testcase_14 | AC | 340 ms
204,512 KB |
testcase_15 | AC | 59 ms
130,384 KB |
testcase_16 | AC | 60 ms
132,436 KB |
testcase_17 | AC | 41 ms
105,752 KB |
testcase_18 | AC | 50 ms
120,084 KB |
testcase_19 | AC | 51 ms
120,088 KB |
testcase_20 | AC | 40 ms
103,764 KB |
testcase_21 | AC | 60 ms
132,628 KB |
testcase_22 | AC | 59 ms
132,380 KB |
testcase_23 | AC | 50 ms
120,208 KB |
testcase_24 | AC | 49 ms
118,040 KB |
testcase_25 | AC | 28 ms
83,488 KB |
testcase_26 | AC | 40 ms
103,820 KB |
testcase_27 | AC | 67 ms
140,544 KB |
testcase_28 | AC | 51 ms
120,092 KB |
testcase_29 | AC | 49 ms
116,044 KB |
testcase_30 | AC | 1,266 ms
370,288 KB |
testcase_31 | AC | 1,254 ms
370,028 KB |
testcase_32 | AC | 1,258 ms
370,084 KB |
testcase_33 | AC | 1,260 ms
369,960 KB |
testcase_34 | AC | 1,200 ms
369,104 KB |
testcase_35 | AC | 1,234 ms
370,020 KB |
testcase_36 | AC | 1,203 ms
363,884 KB |
testcase_37 | AC | 1,194 ms
363,836 KB |
testcase_38 | AC | 1,225 ms
369,336 KB |
testcase_39 | AC | 1,227 ms
369,604 KB |
testcase_40 | AC | 4 ms
13,884 KB |
testcase_41 | AC | 4 ms
13,652 KB |
testcase_42 | AC | 4 ms
13,784 KB |
testcase_43 | AC | 4 ms
15,628 KB |
testcase_44 | AC | 4 ms
13,760 KB |
testcase_45 | AC | 6 ms
26,048 KB |
testcase_46 | AC | 1,303 ms
370,032 KB |
testcase_47 | AC | 1,226 ms
370,272 KB |
testcase_48 | AC | 1,240 ms
370,012 KB |
testcase_49 | AC | 1,069 ms
351,476 KB |
testcase_50 | AC | 1,194 ms
368,424 KB |
testcase_51 | AC | 1,210 ms
370,032 KB |
testcase_52 | AC | 1,170 ms
370,284 KB |
testcase_53 | AC | 1,149 ms
366,108 KB |
testcase_54 | AC | 1,283 ms
370,328 KB |
testcase_55 | AC | 1,191 ms
370,256 KB |
ソースコード
#include <bits/stdc++.h> #include <unistd.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; long long int INF = 3e18; const ll fact_table = 800008; double Pi = 3.1415926535897932384626; //vector<ll> G[550010]; //vector<P> tree[500010]; priority_queue <ll> pql; priority_queue <P> pqp; //big priority queue priority_queue <ll,vector<ll>,greater<ll> > pqls; // priority_queue <P,vector<P>,greater<P> > pqps; //small priority queue //top pop ll dx[8]={1,0,-1,0,1,1,-1,-1}; ll dy[8]={0,1,0,-1,1,-1,-1,1}; char dir[] = "DRUL"; //ll bit[500005]; //↓,→,↑,← #define p(x) cout<<x<<"\n"; #define el cout<<endl; #define pe(x) cout<<(x)<<" "; #define ps(x) cout<<fixed<<setprecision(25)<<x<<endl; #define pu(x) cout<<(x); #define pb push_back #define lb lower_bound #define ub upper_bound #define CLEAR(a) a = decltype(a)(); //ll mod = 998244353; ll mod = 1000000007; ll rui(ll number1,ll number2){ if(number2 == 0){ return 1; }else{ ll number3 = rui(number1,number2 / 2); number3 *= number3; number3 %= mod; if(number2%2==1){ number3 *= number1; number3 %= mod; } return number3; } } ll gcd(ll number1,ll number2){ if(number1 > number2){ swap(number1,number2); } if(number1 == 0 || number1 == number2){ return number2; }else{ return gcd(number2 % number1,number1); } } void YES(bool condition){ if(condition){ p("YES"); }else{ p("NO"); } return; } void Yes(bool condition){ if(condition){ p("Yes"); }else{ p("No"); } return; } /* ll fact[fact_table + 5],rfact[fact_table + 5]; void c3_init(){ fact[0] = rfact[0] = 1; for(ll i=1; i<=fact_table; i++){ fact[i] = (fact[i-1]*i) % mod; } rfact[fact_table] = rui(fact[fact_table],mod - 2); for(ll i=fact_table; i>=1; i--){ rfact[i-1] = rfact[i] * i; rfact[i-1] %= mod; } return;} ll c3(ll n,ll r){ return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;} */ ll n,m,num,sum,a,b,c,d,e,g,h,w, i,j,q,r,l; ll k; ll ans; ll x[500005], y[200005], z[200005]; // char s[500005], t[500005]; bool used[3005][3004]; ll dp[5004][5004]; ll sum_l[5005][5005]; ll sum_r[5005][5005]; char s[2005][2005]; ll ruiseki(ll l, ll r){ return y[r] - y[l]; } int main(){ /* cin.tie(0); ios::sync_with_stdio(false); */ cin >> n >> k; for(ll i=0;i<n;i++){ cin >> x[i]; } for(ll i=0;i<n;i++){ y[i+1] = x[i]; } for(ll i=0;i<n;i++){ y[i+2] += y[i+1]; } for(ll l=0;l<n;l++){ for(ll i=0;i+l<n;i++){ ll j = i + l; bool canwin = false; // dp[i][j]はどうなるか? if(i == j){ dp[i][j] = 2; sum_l[i][j] = 2; sum_r[i][j] = 2; continue; } // 左から食べる場合 ll ok = i, ng = j + 2; while(ng - ok > 1){ ll mid = (ok + ng) / 2; if(ruiseki(i, mid) <= k){ ok = mid; }else{ ng = mid; } } if(ok >= j){ canwin = true; } // ruiseki(i, ok) <= k ll tmp1 = sum_l[i+1][j] - sum_l[ok+1][j]; ll kosuu1 = ok - i; if(tmp1 > kosuu1){ // 負けへの遷移がある canwin = true; } if(canwin){ dp[i][j] = 1; sum_r[i][j] = sum_r[i][j-1] + dp[i][j]; sum_l[i][j] = sum_l[i+1][j] + dp[i][j]; continue; } // 右から食べる場合 ok = j+1, ng = i - 1; while(ok - ng > 1){ ll mid = (ok + ng) / 2; if(ruiseki(mid, j+1) <= k){ ok = mid; }else{ ng = mid; } } if(ok <= i + 1){ canwin = true; } ll tmp2 = sum_r[i][j-1] - sum_r[i][ok-2]; ll kosuu2 = j - ok + 1; if(tmp2 > kosuu2){ // 負けへの遷移がある canwin = true; } if(canwin){ dp[i][j] = 1; }else{ dp[i][j] = 2; } sum_r[i][j] = sum_r[i][j-1] + dp[i][j]; sum_l[i][j] = sum_l[i+1][j] + dp[i][j]; } } if(dp[0][n-1] == 2){ p("B"); }else{ p("A"); } return 0; }