Submission #74687

#TimeUsernameProblemLanguageResultExecution timeMemory
74687shoemakerjoCalvinball championship (CEOI15_teams)C++14
100 / 100
215 ms1168 KiB
#include <bits/stdc++.h> using namespace std; const int mod = 1000007; #define maxn 10010 int dp[2][maxn]; int n; int nums[maxn]; int maxbef[maxn]; int main() { fill(dp[0], dp[0]+maxn, 1); fill(dp[1], dp[1]+maxn, 1); ios_base::sync_with_stdio(false); cin.tie(NULL); int cur = 0, prev = 1; cin >> n; //going to do 1-indexed for (int i = 1; i <= n; i++) { cin >> nums[i]; } for (int i = 1; i <= n; i++) { maxbef[i] = max(maxbef[i-1], nums[i-1]); } int ans = 0; for (int i = n; i >= 1; i--, swap(prev, cur)) { for (int j = 1; j <= i; j++) { //this whole thing is free range dp[cur][j] = (j*1LL*dp[prev][j])%mod; dp[cur][j] = (dp[cur][j] + dp[prev][j+1])%mod; } int val = 0; val = (val + (nums[i]-1)*1LL*dp[prev][maxbef[i]])%mod; ans = (ans+val)%mod; } cout << ans+1 << endl; //think we want the plus 1 }
#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...