Submission #527110

#TimeUsernameProblemLanguageResultExecution timeMemory
527110ecxxCalvinball championship (CEOI15_teams)C++17
70 / 100
33 ms65540 KiB
#include <bits/stdc++.h> using namespace std; int MOD = 1000007; vector<int> seq; vector<vector<vector<int> > > dp; int recurse(int strict, int i, int maxN) { if (dp[strict][i][maxN] > -1) { return dp[strict][i][maxN]; } if (i==0) { if (strict) return dp[strict][i][maxN] = seq[i]; else return dp[strict][i][maxN] = (maxN + 1); } int poss = 0; if (strict) { poss += recurse(1, i-1, max(seq[i], maxN)); poss %= MOD; if (seq[i]>1) poss += (seq[i]-1) * recurse(0, i-1, maxN); poss %= MOD; } else { poss += maxN * recurse(0, i-1, maxN); poss %= MOD; poss += recurse(0, i-1, maxN+1); poss %= MOD; } dp[strict][i][maxN] = poss; return poss; } int main() { int N;cin>>N; seq.assign(N, 0); dp.assign(2, vector<vector<int> >(N, vector<int>(N+1, -1))); for (int i = N-1; i >= 0; i--) { cin >> seq[i]; } cout << recurse(1, N-1, 1) << endl; }
#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...