#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e6 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
int dp[1005][1005][2];
signed main() {
int n;
cin >> n;
vector<int> v(n+1);
for(int i=1; i<=n; i++) cin >> v[i];
dp[1][1][0] = 1;
for(int a=1; a<n; a++) {
for(int b=1; b<=a; b++) {
for(int c=0; c<2; c++) {
for(int i=1; i<=b+1; i++) {
if(!c && i > v[a+1]) break;
dp[a+1][max(b, i)][c|(i<v[a+1])] = (dp[a+1][max(b, i)][c|(i<v[a+1])] + dp[a][b][c]) % mod;
}
}
}
}
long long ans = 0;
for(int i=1; i<=n; i++) ans = (ans + dp[n][i][1]) % mod;
cout << (ans + 1) % mod << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
860 KB |
Output is correct |
2 |
Correct |
1 ms |
860 KB |
Output is correct |
3 |
Correct |
2 ms |
800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
4176 KB |
Output is correct |
2 |
Correct |
86 ms |
4252 KB |
Output is correct |
3 |
Correct |
152 ms |
4308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
621 ms |
11604 KB |
Output is correct |
2 |
Correct |
626 ms |
11756 KB |
Output is correct |
3 |
Execution timed out |
1014 ms |
11088 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1069 ms |
11256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
643 ms |
23684 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
672 ms |
23728 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |