# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
46863 | HachikujiMayoi | Calvinball championship (CEOI15_teams) | C++14 | 131 ms | 1256 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 N = 10007;
const long long mod = 1000007;
long long dp[N][2];
int C[N];
int main(){
int n;
scanf("%d", &n);
for(int i = 1; i <= n; ++i){
scanf("%d", &C[i]);
}
int M = 0;
for(int i = 1; i <= n; ++i){
int B = i & 1;
for(int j = 1; j <= i; ++j){
dp[j][B] = (dp[j][B ^ 1] * j + dp[j - 1][B ^ 1]) % mod;
}
dp[M][B] = (dp[M][B] + C[i] - 1) % mod;
M = max(M, C[i]);
}
long long ans = 1;
for(int i = 1; i <= n; ++i){
ans += dp[i][n & 1];
ans %= mod;
}
printf("%lld\n", 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... |