結果

問題 No.973 余興
ユーザー ttttan2ttttan2
提出日時 2020-01-18 00:16:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 839 ms / 4,000 ms
コード長 2,833 bytes
コンパイル時間 2,274 ms
コンパイル使用メモリ 146,528 KB
実行使用メモリ 288,832 KB
最終ジャッジ日時 2023-09-08 09:26:46
合計ジャッジ時間 20,055 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 827 ms
265,820 KB
testcase_01 AC 839 ms
265,608 KB
testcase_02 AC 789 ms
265,492 KB
testcase_03 AC 699 ms
270,720 KB
testcase_04 AC 711 ms
285,576 KB
testcase_05 AC 669 ms
281,748 KB
testcase_06 AC 674 ms
286,340 KB
testcase_07 AC 658 ms
281,252 KB
testcase_08 AC 664 ms
286,484 KB
testcase_09 AC 666 ms
281,588 KB
testcase_10 AC 640 ms
282,568 KB
testcase_11 AC 81 ms
107,752 KB
testcase_12 AC 84 ms
107,980 KB
testcase_13 AC 80 ms
107,372 KB
testcase_14 AC 90 ms
106,876 KB
testcase_15 AC 22 ms
15,064 KB
testcase_16 AC 24 ms
15,396 KB
testcase_17 AC 13 ms
10,612 KB
testcase_18 AC 18 ms
12,888 KB
testcase_19 AC 18 ms
12,916 KB
testcase_20 AC 13 ms
10,468 KB
testcase_21 AC 22 ms
15,132 KB
testcase_22 AC 23 ms
15,292 KB
testcase_23 AC 18 ms
12,896 KB
testcase_24 AC 17 ms
12,712 KB
testcase_25 AC 9 ms
7,572 KB
testcase_26 AC 13 ms
10,456 KB
testcase_27 AC 27 ms
17,324 KB
testcase_28 AC 19 ms
12,872 KB
testcase_29 AC 17 ms
12,576 KB
testcase_30 AC 283 ms
281,432 KB
testcase_31 AC 302 ms
287,296 KB
testcase_32 AC 288 ms
281,460 KB
testcase_33 AC 304 ms
286,912 KB
testcase_34 AC 299 ms
280,764 KB
testcase_35 AC 306 ms
287,468 KB
testcase_36 AC 288 ms
279,064 KB
testcase_37 AC 296 ms
278,092 KB
testcase_38 AC 290 ms
281,800 KB
testcase_39 AC 316 ms
287,704 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 2 ms
4,384 KB
testcase_43 AC 2 ms
4,376 KB
testcase_44 AC 1 ms
4,376 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 288 ms
282,568 KB
testcase_47 AC 306 ms
286,516 KB
testcase_48 AC 289 ms
282,396 KB
testcase_49 AC 263 ms
272,420 KB
testcase_50 AC 281 ms
279,468 KB
testcase_51 AC 302 ms
288,832 KB
testcase_52 AC 282 ms
279,440 KB
testcase_53 AC 289 ms
286,192 KB
testcase_54 AC 281 ms
280,400 KB
testcase_55 AC 312 ms
286,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n,x;cin>>n>>x;
    ll a[n];
    rep(i,0,n)cin>>a[i];
    ll sum[n+1];
    sum[0]=0;
    rep(i,0,n)sum[i+1]=sum[i]+a[i];
    ll dp[n+2][n+2];
    memset(dp,0,sizeof dp);
    int ans[n+1][n+1];
    rep(l,1,n+1){
        rep(k,1,n-l+2){
            int i=k,j=k+l-1;
            dp[i][j]+=dp[i+1][j]+dp[i][j-1]-dp[i+1][j-1];
            if(dp[i][j]>0)ans[i][j]=1;
            else ans[i][j]=0;
            if(l==n&&k==1){
                if(dp[i][j]>0)cout<<"A"<<endl;
                else cout<<"B"<<endl;
                /*rep(p,1,n+1){
                    rep(q,p,n+1)cout<<ans[p][q]<<" ";
                    cout<<endl;
                }*/
                return 0;
            }
            if(dp[i][j]>0)continue;
            ll u=n+1,d=j;
            while(u-d>1){
                ll mid=(u+d)/2;
                ll t=sum[mid]-sum[j];
                if(t>x)u=mid;
                else d=mid;
            }
            ll uu=i,dd=0;
            while(uu-dd>1){
                ll mid=(uu+dd)/2;
                ll t=sum[i-1]-sum[mid-1];
                if(t>x)dd=mid;
                else uu=mid;
            }
          // cout<<i<<" "<<j<<" "<<d<<" "<<uu<<endl;
            dp[i][j]++;
            dp[uu-1][j]--;
            dp[i][j+1]--;
            dp[uu-1][j+1]++;
            dp[i][j+1]++;
            dp[i-1][j+1]--;
            dp[i][d+1]--;
            dp[i-1][d+1]++;
        }
    }
}
0