結果
問題 |
No.973 余興
|
ユーザー |
![]() |
提出日時 | 2020-01-18 00:16:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1,105 ms / 4,000 ms |
コード長 | 2,833 bytes |
コンパイル時間 | 1,511 ms |
コンパイル使用メモリ | 161,972 KB |
実行使用メモリ | 296,704 KB |
最終ジャッジ日時 | 2024-06-26 02:30:44 |
合計ジャッジ時間 | 30,873 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 54 |
ソースコード
#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]++; } } }