Submission #720490

#TimeUsernameProblemLanguageResultExecution timeMemory
720490mariowongCalvinball championship (CEOI15_teams)C++14
100 / 100
186 ms884 KiB
#include <bits/stdc++.h> const long long xmod=1000007; using namespace std; long long dp[10005][5],a[10005],mx[10005]; int main(){ ios::sync_with_stdio(false); int n; cin >> n; long long ans=1; for (int i=1;i<=n;i++) cin >> a[i]; for (int i=1;i<=n;i++) mx[i]=max(mx[i-1],a[i]); for (int i=1;i<=n+1;i++) dp[i][(n+1)%2]=1; for (int i=n;i>=1;i--){ ans+=(dp[mx[i-1]][(i+1)%2]*(a[i]-1))%xmod; ans%=xmod; for (long long j=1;j<i;j++){ dp[j][i%2]=dp[j+1][(i+1)%2]; dp[j][i%2]+=(j*(dp[j][(i+1)%2]))%xmod; dp[j][i%2]%=xmod; } } 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...