Submission #1004643

#TimeUsernameProblemLanguageResultExecution timeMemory
1004643Valaki2Calvinball championship (CEOI15_teams)C++14
10 / 100
265 ms640 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define pii pair<int, int> #define fi first #define se second const int mod = 1e6 + 7; void solve() { int n; cin >> n; vector<int> v(1 + n, 0); for(int i = 1; i <= n; i++) { cin >> v[i]; } vector<int> dp(1 + n, 0); for(int i = 1; i <= n; i++) { dp[i] = 1; } int ans = 0; for(int i = n; i >= 1; i--) { for(int j = 1; j <= v[i] - 1; j++) { ans += dp[j]; ans %= mod; } for(int j = 1; j <= i - 1; j++) { dp[j] = dp[j] * j + dp[j + 1]; dp[j] %= mod; } } ans++; ans %= mod; cout << ans << "\n"; } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); solve(); }
#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...