Submission #476127

#TimeUsernameProblemLanguageResultExecution timeMemory
476127elgamalsalmanCalvinball championship (CEOI15_teams)C++14
100 / 100
724 ms660 KiB
#include <bits/stdc++.h> using namespace std; #define MODVAL 1000007 typedef long long ll; typedef vector<int> vi; int n, m[10010]; ll dp[200020]; vi a; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; a = {1}; for (int i = 0; i < n; i++) { int tmp; cin >> tmp; a.push_back(tmp); } n++; reverse(a.begin(), a.end()); int mx = 1; for (int i = n - 1; i >= 0; i--) { if (a[i] > mx) mx = a[i]; m[i] = mx; } fill(dp, dp + 2 * n + 10, 1); ll ans = 1; for (int i = 0; i < n - 1; i++) { if (i) for (int j = 0; j < 2 * n + 5; j++) { dp[j] *= j; dp[j] %= MODVAL; dp[j] += dp[j + 1]; dp[j] %= MODVAL; } ans += ((a[i] - 1) * dp[m[i + 1]]) % MODVAL; ans %= MODVAL; } cout << ans << '\n'; }
#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...