#include<bits/stdc++.h>
using namespace std;
const int mod = 1000007;
int n, v[10002];
int dp[1002][1002];
int add(int a, int b)
{
int ans = a+b;
if(ans >= mod)
ans -= mod;
return ans;
}
long long mul(long long a, long long b)
{
return (a * b) % mod;
}
int main()
{
cin >> n;
int maxi = 1;
for(int i = 1; i <= n; ++i)
{
cin >> v[i];
dp[i][max(v[i], maxi) - (v[i] > maxi)] = v[i] - 1;
maxi = max(maxi, v[i]);
}
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= i; ++j)
{
dp[i+1][j] = add(dp[i+1][j], mul(dp[i][j], j));
dp[i+1][j+1] = add(dp[i+1][j+1], dp[i][j]);
}
int sum = 1;
for(int i = 1; i <= n; ++i)
sum = add(sum, dp[n][i]);
cout << sum;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
380 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
760 KB |
Output is correct |
2 |
Correct |
5 ms |
760 KB |
Output is correct |
3 |
Correct |
5 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2296 KB |
Output is correct |
2 |
Correct |
6 ms |
2296 KB |
Output is correct |
3 |
Correct |
6 ms |
2296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
4216 KB |
Output is correct |
2 |
Correct |
10 ms |
4216 KB |
Output is correct |
3 |
Correct |
9 ms |
4216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
12 ms |
8440 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
12 ms |
8440 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
12 ms |
8440 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |