(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #1079413

#TimeUsernameProblemLanguageResultExecution timeMemory
1079413alexander707070Skyscraper (JOI16_skyscraper)C++14
20 / 100
2054 ms122448 KiB
#include<bits/stdc++.h> #define MAXN 107 #define MAXS 6007 using namespace std; const long long mod=1e9+7; int n,s,a[MAXN],ans,pref[2*MAXN]; int dp[MAXN][MAXN/2+7][3][3][MAXS]; bool li[MAXN][MAXN/2+7][3][3][MAXS]; bool ok(int sum){ return true; // return sum>=-5000 and sum<=s; } long long even(int pos,int bal,int sum,int l,int r){ if(sum>s or bal>n/2+5)return 0; if(sum+pref[pos+(bal-5)-2]-pref[pos-1]>s)return 0; long long free=2*(bal-5)+(-(l==1)-(r==1)) - (-(l==2)-(r==2)); if(free<0)return 0; if(pos==n+1 and bal==5 and l+r==3 and free==0)return 1; else if(pos==n+1 and (bal==4 or bal==6) and l==r and l!=0 and free==0)return 1; else if(pos==n+1)return 0; if(free==0 and pos!=1)return 0; if(sum>=-4000 and li[pos][bal][l][r][sum+4000])return dp[pos][bal][l][r][sum+4000]; if(sum>=-4000)li[pos][bal][l][r][sum+4000]=true; long long curr=0; curr+=even(pos+1,bal,sum,l,r)*free; if(l==0){ curr+=even(pos+1,bal+1,sum-a[pos],1,r); curr+=even(pos+1,bal-1,sum+a[pos],2,r); } if(r==0){ curr+=even(pos+1,bal+1,sum-a[pos],l,1); curr+=even(pos+1,bal-1,sum+a[pos],l,2); } long long mult=bal-5+1-(l==1)-(r==1); long long mult2=bal-5-1+(l==2)+(r==2); curr+=even(pos+1,bal+1,sum-2*a[pos],l,r)*mult; curr+=even(pos+1,bal-1,sum+2*a[pos],l,r)*mult2; curr%=mod; if(sum>=-4000)dp[pos][bal][l][r][sum+4000]=curr; return curr; } void calc_even(){ ans+=even(1,5,0,0,0); } int main(){ cin>>n>>s; int mins=1000; if(n==1){ cout<<1<<"\n"; return 0; } for(int i=1;i<=n;i++){ cin>>a[i]; } sort(a+1,a+n+1); mins=a[1]; for(int i=1;i<=n;i++){ a[i]-=mins; pref[i]=pref[i-1]+a[i]; } for(int i=n+1;i<=2*n;i++){ pref[i]=pref[i-1]; } calc_even(); cout<<ans%mod<<"\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...