結果

問題 No.973 余興
ユーザー ttttan2ttttan2
提出日時 2020-01-17 23:50:00
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,681 bytes
コンパイル時間 2,362 ms
コンパイル使用メモリ 146,280 KB
実行使用メモリ 296,528 KB
最終ジャッジ日時 2023-09-08 08:42:26
合計ジャッジ時間 18,918 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 557 ms
295,084 KB
testcase_01 WA -
testcase_02 AC 560 ms
295,152 KB
testcase_03 AC 556 ms
295,384 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 532 ms
284,352 KB
testcase_11 WA -
testcase_12 AC 113 ms
107,956 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 10 ms
10,660 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 17 ms
15,280 KB
testcase_23 AC 14 ms
12,876 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 21 ms
17,092 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 346 ms
294,152 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 360 ms
294,632 KB
testcase_39 WA -
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 WA -
testcase_44 AC 1 ms
4,380 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 359 ms
295,208 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 355 ms
289,824 KB
testcase_54 WA -
testcase_55 WA -
権限があれば一括ダウンロードができます

ソースコード

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]-sum[mid];
                if(t>x)dd=mid;
                else uu=mid;
            }
            
            dp[i][j]++;
            dp[uu-1][j]--;
            dp[i][d+1]--;
            dp[uu-1][d+1]++;
        }
    }
}
0