#include <bits/stdc++.h>
using namespace std;
int MOD = 1000007;
vector<int> seq;
vector<vector<int > > dp;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int N, dpns, dps;cin>>N;
seq.assign(N, 0);
dp.assign(2, vector<int>(N+2, -1));
for (int i = N-1; i >= 0; i--) {
cin >> seq[i];
}
for (int j = 0; j < N+1; j++) {
dp[0][j] = j+1;
dp[1][j] = seq[0];
}
for (int i = 1; i < N; i++) {
for (int j = 0; j < N+1; j++) {
dpns = j * dp[0][j] + dp[0][j+1];
dpns %= MOD;
dps = (dp[1][max(seq[i], j)]) + ((seq[i]-1)*dp[0][j]);
dps %= MOD;
dp[1][j] = dps;
dp[0][j] = dpns;
}
}
cout << dp[1][1] << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
204 KB |
Output is correct |
2 |
Correct |
3 ms |
204 KB |
Output is correct |
3 |
Correct |
3 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
332 KB |
Output is correct |
2 |
Correct |
12 ms |
324 KB |
Output is correct |
3 |
Correct |
12 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1085 ms |
460 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
290 ms |
372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1082 ms |
460 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |