Submission #527318

#TimeUsernameProblemLanguageResultExecution timeMemory
527318squiddyCalvinball championship (CEOI15_teams)C++14
70 / 100
56 ms65540 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(v, s, e) for (int v = s; v < e; v++) #define FOR_REV(v, s, e) for (int v = e - 1; v >= s; v--) #define int long long #define MOD 1000007 int n, ans, cmax = 1; vector<vector<int>> dp; int cval; int32_t main() { cin >> n; dp.resize(n); dp[0].resize(n); FOR(i, 0, n) { dp[0][i] = 1; } FOR(i, 1, n) { dp[i].resize(n - i); FOR(j, 0, n - i) { dp[i][j] = ((j + 1) * dp[i - 1][j] + dp[i - 1][j + 1]) % MOD; } } FOR_REV(i, 0, n) { cin >> cval; //cout << cmax << ' '; ans = (ans + (cval - 1) * dp[i][cmax - 1]) % MOD; cmax = max(cmax, cval); } cout << (ans + 1) % MOD; }
#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...