# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
156360 | Akashi | Calvinball championship (CEOI15_teams) | C++14 | 288 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.
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000007;
int n;
int a[10005], Max[10005];
int d[2][10005];
int main()
{
scanf("%d", &n);
for(int i = 1; i <= n ; ++i)
scanf("%d", &a[i]), Max[i] = max(Max[i - 1], a[i]);
int l = 0, cnt = 1;
for(int i = 1; i <= n ; ++i) d[0][i] = 1;
for(int i = n; i >= 1 ; --i){
for(int j = 1; j <= a[i] - 1 ; ++j){
cnt += d[l][Max[i - 1]];
if(cnt >= MOD) cnt -= MOD;
}
l = 1 - l;
for(int j = 1; j <= n ; ++j)
d[l][j] = (1LL * d[1 - l][j] * j + d[1 - l][j + 1]) % MOD;
}
printf("%d", cnt);
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... |