# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1121841 | coolboy19521 | Calvinball championship (CEOI15_teams) | C++17 | 132 ms | 65536 KiB |
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;
const int md = 1000007;
const int mxN = 10004;
int dp[mxN][mxN];
int a[mxN];
main() {
int N;
cin >> N;
for (int i = 1; i <= N; i ++) {
cin >> a[i];
}
for (int i = 1; i <= N + 1; i ++) {
assert(N + 1 < mxN && i < mxN);
dp[N + 1][i] = 1;
}
for (int i = N; 1 <= i; i --) {
for (int j = i; 1 <= j; j --) {
assert(j + 1 < mxN && i + 1 < mxN);
dp[i][j] = (dp[i][j] + 1ll * dp[i + 1][j] * j % md) % md;
dp[i][j] = (dp[i][j] + 1ll * dp[i + 1][j + 1]) % md;
}
}
int ans = 0;
int mx = 0;
for (int i = 1; i <= N; i ++) {
mx = max(mx, a[i - 1]);
for (int j = a[i] - 1; 1 <= j; j --) {
assert(max(mx, j) < mxN && i + 1 < mxN);
ans = (0ll + ans + dp[i + 1][max(mx, j)]) % md;
}
}
cout << (ans + 1ll) % md << endl;
}
Compilation message (stderr)
# | 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... |