Submission #126055

#TimeUsernameProblemLanguageResultExecution timeMemory
126055Mahmoud_AdelCalvinball championship (CEOI15_teams)C++11
20 / 100
23 ms16248 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second typedef long long ll; const int N = 1e3+5; ll n, dp[N][N][2], a[N]; ll sol(int i, ll j, int bit) { if(i == n) return 1; ll &ret = dp[i][j][bit]; if(ret != -1) return ret; if(bit) return ret = j*sol(i+1, j, 1) + sol(i+1, j+1, 1); else return ret = (a[i]-1)*sol(i+1, max(j, a[i]-1), 1) + sol(i+1, max(j, a[i]), 0); } int main() { memset(dp, -1, sizeof dp); cin >> n; for(int i=0; i<n; i++) cin >> a[i]; cout << sol(0, 0, 0) << 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...