Submission #527327

#TimeUsernameProblemLanguageResultExecution timeMemory
527327squiddyCalvinball championship (CEOI15_teams)C++14
100 / 100
194 ms648 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; int val[10005], cmax[10005]; int dp[2][10005]; int32_t main() { cin >> n; cmax[n - 1] = 1; FOR_REV(i, 0, n) { cin >> val[i]; if (i != 0) cmax[i - 1] = max(cmax[i], val[i]); } FOR(i, 0, n) { dp[0][i] = 1; } bool flag = false; FOR(i, 0, n) { ans = (ans + (val[i] - 1) * dp[flag][cmax[i] - 1]) % MOD; FOR(j, 0, n - 1) { dp[1 - flag][j] = ((j + 1) * dp[flag][j] + dp[flag][j + 1]) % MOD; } flag = 1 - flag; } 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...