This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#define mod 1000007
using namespace std;
int n, t, i, j, k;
int d[2][10005], v[10005], maxim[10005];
int main(){
cin>> n;
for(i = 1; i <= n; i++){
cin>> v[i];
maxim[i] = max(maxim[i - 1], v[i]);
}
for(i = 1; i <= n; i++){
d[0][i] = 1;
}
t = 1;
for(i = n; i >= 2; i--){
for(j = 1; j < i; j++){
d[t][j] = d[1 - t][j + 1];
d[t][j] = (d[t][j] + j * 1LL * d[1 - t][j]) % mod;
}
for(j = 1; j < v[i]; j++){
k = (k + d[1 - t][ maxim[i - 1] ]) % mod;
}
t = 1 - t;
}
k = (1 + k) % mod;
cout<< k;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |