This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 = 0; i < N; ++i) {
cin >> A[i]; A[i]--;
}
for (long long i = 0; i < N; ++i) dp[N][i] = 1;
for (long long i = N-1; i >= 0; --i) for (long long j = 0; j < N; ++j) dp[i][j] = (dp[i+1][j] * j + dp[i+1][j+1]) % p;
long long ans = 0, most = 0;
for (long long i = 0; i < N; ++i) {
for (long long j = 0; j < A[i]; ++j) ans += dp[i][max(most,j)];
most = max(most,A[i]);
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |