#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e6 + 7;
int n;
vector<int> a;
const int N = 1e4 + 100;
ll dp[N][N];
int main ()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
a.resize( n );
for ( auto& el : a )
cin >> el;
for ( int i=0; i<N; i++ )
for ( int j=0; j<N; j++ )
dp[i][j] = 0;
for ( int i=1; i<=n; i++ )
dp[0][i] = 1;
for ( int i=1; i<=n; i++ )
for ( int j=1; j<=n; j++ )
dp[i][j] = ( j*dp[i-1][j] + ( j<n ? dp[i-1][j+1] : 0 ) ) % MOD;
ll ans = 1;
int maxi = 0;
for ( int i=0; i<n; i++ )
{
for ( int j=1; j < a[i]; j++ )
ans = ( ans + dp[n-1-i][ max( maxi, j ) ] ) % MOD;
maxi = max( maxi, a[i] );
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
33 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
34 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
34 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
31 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
28 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
29 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
33 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
32 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
37 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
30 ms |
65536 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |