Submission #366021

#TimeUsernameProblemLanguageResultExecution timeMemory
366021kostia244Calvinball championship (CEOI15_teams)C++17
100 / 100
205 ms620 KiB
#include<bits/stdc++.h> #define all(x) begin(x), end(x) using namespace std; using ll = long long; const int maxn = 1e4+1, mod = 1e6 + 7; using state = array<int, maxn>; int n; state def; void add(int &a, int b) { a = a+b>=mod?a+b-mod:a+b; } int main() { cin.tie(0)->sync_with_stdio(0); cin >> n; def.fill(0); state dp = def; int lk = 0; for(int A, i = 1; i <= n; i++) { cin >> A; auto ndp = def; add(ndp[lk], A-1); lk = max(lk, A); for(int k = 0; k < i; k++) { ndp[k] = (ndp[k] + dp[k]*1ll*k)%mod; add(ndp[k+1], dp[k]); } dp = ndp; //for(int i = 0; i <= n; i++) cout << dp[i] << " "; cout << endl; } int sm = 1; for(int i = 0; i <= n; i++) add(sm, dp[i]); cout << sm << '\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...