# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
244444 | dwsc | Calvinball championship (CEOI15_teams) | C++14 | 732 ms | 888 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>
#define int long long
using namespace std;
int MOD = 1e6+7;
int memo[2][10010][2];
int arr[10010];
int n;
main(){
cin >> n;
for (int i = 0; i < n; i++){
int x;
cin >> x;
arr[i] = x;
}
for (int i = 0; i <= n; i++) memo[n%2][i][0] = memo[n%2][i][1] = 1;
for (int i = n-1; i >= 0; i--){
for (int j = 0; j <= i; j++){
int curnum = arr[i];
int ans = ((curnum-1)*memo[1-i%2][j][0]);
ans += memo[1-i%2][max(j,curnum)][1];
memo[i%2][j][1] = ans%MOD;
int ans2 = (j*memo[1-i%2][j][0]) + memo[1-i%2][j+1][0];
memo[i%2][j][0] = ans2%MOD;
}
}
cout << memo[0][0][1];
}
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... |