Submission #527147

#TimeUsernameProblemLanguageResultExecution timeMemory
527147joelauCalvinball championship (CEOI15_teams)C++14
50 / 100
1 ms844 KiB
#include <bits/stdc++.h> using namespace std; long long N, A[105], dp[1005][1005], p = 1000007; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> N; for (long long i = 1; i <= N; ++i) cin >> A[i]; for (long long i = 1; i <= N; ++i) dp[N+1][i] = 1; for (long long i = N; i > 0; --i) for (long long j = 1; j <= N; ++j) dp[i][j] = (dp[i+1][j] * j + dp[i+1][j+1]) % p; long long ans = 1, most = 0; for (long long i = 1; i <= N; ++i) { ans = (ans + dp[i+1][most] * min(most,A[i]-1)) % p; for (long long j = most+1; j < A[i]; ++j) ans = (ans + dp[i+1][j]) % p; most = max(most,A[i]); } cout << ans; return 0; }
#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...