#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 1100;
const ll mod = 1000007;
int dp[maxn][maxn];
int a[maxn], n;
bool important[maxn];
int main() {
// dp[i][j] -> If we are given a sequence of arbitrary length and maximum element j,
// on how many ways can we extend it if we can add exactly i elements
cin>>n;
for(int i=1;i<=n;i++) {
dp[0][i] = 1;
}
for(int i=1;i<=n;i++) {
//cout<<i<<": \n";
for(int j=1;j<=n;j++) {
dp[i][j] = j*dp[i-1][j] + dp[i-1][j+1];
dp[i][j] %= mod;
//cout<<j<<": "<<dp[i][j]<<"\n";
}
}
int result = 0;
int maxv = 1;
for(int i=1;i<=n;i++) {
cin>>a[i];
result += (a[i]-1)*(dp[n-i][maxv]); result %= mod;
maxv = max(maxv, a[i]);
}
cout<<(result+1)%mod;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
768 KB |
Output is correct |
2 |
Correct |
3 ms |
768 KB |
Output is correct |
3 |
Correct |
3 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
2560 KB |
Output is correct |
2 |
Correct |
6 ms |
2560 KB |
Output is correct |
3 |
Correct |
5 ms |
2432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
4608 KB |
Output is correct |
2 |
Correct |
8 ms |
4672 KB |
Output is correct |
3 |
Correct |
8 ms |
4608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
34 ms |
9976 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
24 ms |
9856 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
38 ms |
9948 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |