Submission #559429

#TimeUsernameProblemLanguageResultExecution timeMemory
559429groshiCalvinball championship (CEOI15_teams)C++17
100 / 100
681 ms616 KiB
#include<iostream> using namespace std; int t[200000]; int mod=1e6+7; long long dp[2][200000]; int maxx[200000]; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int n; cin>>n; for(int i=1;i<=n;i++) cin>>t[i]; for(int i=1;i<=n;i++) dp[0][i]=1; long long wynik=1; for(int i=1;i<=n;i++) maxx[i]=max(maxx[i-1],t[i]); for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) dp[i%2][j]=(j*dp[(i-1)%2][j]+dp[(i-1)%2][j+1])%mod; wynik+=(t[n-i+1]-1)*dp[(i-1)%2][maxx[n-i]]; wynik%=mod; } cout<<wynik; 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...