Submission #89386

#TimeUsernameProblemLanguageResultExecution timeMemory
89386sjhuang26Calvinball championship (CEOI15_teams)C++14
30 / 100
110 ms848 KiB
#include<iostream> using namespace std; int a[10000],N,x[10000]; typedef long long ll; ll d[2][10001];//given at nth position (implicit, reverse) and cutoff index (starts at 0): # of possibilities? const int md=1e6+7,ans=0; int main(){ cin>>N; for(int i=0;i<N;++i)cin>>a[i]; int u=0,ans=0; for(int i=0;i<N;++i){ x[i]=u=max(u,a[i]); } for(int i=0;i<=N;++i){ d[N%2][i]=1; } for(int i=N-1;i>=0;--i){ for(int j=0;j<=i;++j){ d[i%2][j]=(d[(i+1)%2][j+1]+d[(i+1)%2][j]*j)%md; } if(i==N-1){ ans+=(d[i%2][a[i]-1]); }else{ ans+=(d[(i+1)%2][x[i]-1]*(a[i]-1)); } ans%=md; //cout<<ans<<endl; } cout<<ans<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...