# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44748 | RayaBurong25_1 | Calvinball championship (CEOI15_teams) | C++17 | 402 ms | 944 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 <stdio.h>
#define MOD 1000007LL
int n;
int a[10005];
int mx[10005];
long long dp[10005];
long long max(long long a, long long b)
{
return (a > b)?a:b;
}
int main()
{
scanf("%d", &n);
int i, j;
for (i = 0; i < n; i++)
scanf("%d", &a[i]);
long long ans = 1;
// int mx = 0;
for (i = 0; i < n; i++)
{
if (i == 0)
mx[i] = a[i];
else
mx[i] = max(mx[i - 1], a[i]);
}
for (i = 0; i < n - 1; i++)
{
for (j = 1; j <= n - i; j++)
{
if (i == 0)
dp[j] = 1LL;
else
dp[j] = (1LL*j*dp[j] + dp[j + 1])%MOD;
// if (j <= 2*n - i)
// printf("%d ", dp[j]);
}
// printf("\n");
for (j = 1; j < a[n - 1 - i]; j++)
ans = (ans + dp[max(mx[n - 2 - i], j)])%MOD;
}
// for (i = n - 1; i > 0; i--)
// {
// for (j = 1; j < a[i]; j++)
// ans = (ans + dp[max(mx[i - 1], j)])%MOD;
// // mx = max(mx, a[i]);
// }
printf("%lld", ans);
}
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... |