# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
244494 | shenxy | Calvinball championship (CEOI15_teams) | C++11 | 440 ms | 632 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.
//happy birthday errorgorn
#include <cstdio>
#include <algorithm>
using namespace std;
const long long mod = 1000007;
int main() {
int n;
scanf("%d", &n);
int a[n], sa[n];
long long ans = 1;
for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
sa[0] = a[0];
for (int i = 1; i < n; ++i) sa[i] = max(sa[i - 1], a[i]);
long long dptable[2][n + 1];
fill_n(dptable[0], n + 1, 1);
for (int i = 1; i <= n; ++i) {
for (int j = 1; j < a[n - i]; ++j) ans = (ans + dptable[1 - (i & 1)][max(j, i == n ? 0 : sa[n - i - 1])]) % mod;
for (int j = 0; j < n; ++j) dptable[i & 1][j] = (j * dptable[1 - (i & 1)][j] + dptable[1 - (i & 1)][j + 1]) % mod;
dptable[i & 1][n] = n * dptable[1 - (i & 1)][n] % mod;
}
printf("%lld", ans);
return 0;
}
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... |