# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
34391 | bnahmad15 | Calvinball championship (CEOI15_teams) | C++14 | 476 ms | 2172 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 = 10010,MOD = 1000007;
int n,ar[N],dp[2][N],mx[N],ans = 1;
int main() {
scanf("%d",&n);
mx[0]=0;
for(int i =0 ;i<n;i++){
scanf("%d",&ar[i]);
if (i){
mx[i]=max(mx[i-1],ar[i-1]);
}
}
for (int i = 0 ;i <= n+2 ; i++)
dp[n&1][i]=1;
for (int i = n-1;i >= 0 ;i--){
int m = mx[i];
for (int j =1 ;j < ar[i];j++){
m = max(m,j);
ans += dp[(i+1) & 1][m];
ans %= MOD;
}
for (int j = 1; j<=i+1;j++){
dp[i&1][j]=(long long)dp[(i+1)&1][j]*j % MOD;
dp[i&1][j] += dp[(i+1)&1][j+1];
dp[i&1][j]%= MOD;
}
}
cout<<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... |