# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1121882 | vjudge1 | Calvinball championship (CEOI15_teams) | C++17 | 782 ms | 772 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;
using ll = long long;
#define int ll
const int md = 1000007;
const int mxN = 10004;
int dp[2][mxN];
int a[mxN];
int p[mxN];
int d[mxN];
main() {
int N;
cin >> N;
for (int i = 1; i <= N; i ++) {
cin >> a[i];
}
for (int i = 1; i <= N; i ++) {
p[i] = max(p[i - 1], a[i - 1]);
}
int ans = 0;
dp[1][N + 1] = 1;
for (int j = N; 1 <= j; j --) {
for (int i = N; 1 <= i; i --) {
if (j <= i) {
dp[0][i] = (dp[0][i] + 1ll * dp[0][i + 1] * j % md) % md;
dp[0][i] = (dp[0][i] + 1ll * dp[1][i + 1]) % md;
if (j == p[i]) {
d[i] = dp[0][i];
}
if (j < a[i]) {
if (j <= p[i]) {
ans = (0ll + ans + d[i]);
} else {
ans = (0ll + ans + dp[0][i]);
}
}
}
}
swap(dp[0], dp[1]);
dp[1][N + 1] = 1;
memset(dp[0], 0, sizeof(dp[0]));
}
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... |