#include <bits/stdc++.h>
using namespace std;
int N;
int arr[10005];
int dp[5005][10005];
const int MOD = 1000007;
int solve(int n, int m, bool border){
if(n == N+1){
return 1;
}
if(!border && n%2 == 0 && dp[n/2][m]){
return dp[n/2][m];
}
int lim = m+1;
if(border){
lim = arr[n];
}
long long ans = 1LL * (lim-1) * solve(n+1, m, 0);
ans += solve(n+1, max(lim, m), border);
ans %= MOD;
if(!border && n%2 == 0){
dp[n/2][m] = ans;
}
return ans;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N;
for(int i = 1; i<=N; i++){
cin >> arr[i];
}
cout << solve(1, 0, 1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1664 KB |
Output is correct |
2 |
Correct |
4 ms |
1612 KB |
Output is correct |
3 |
Correct |
4 ms |
1664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
20 ms |
3456 KB |
Output is correct |
2 |
Correct |
15 ms |
3456 KB |
Output is correct |
3 |
Correct |
14 ms |
3456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1060 ms |
65540 KB |
Execution killed with signal 9 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
510 ms |
35192 KB |
Output is correct |
2 |
Correct |
450 ms |
35192 KB |
Output is correct |
3 |
Correct |
486 ms |
35192 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1099 ms |
65540 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |