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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = 1000007;
int n;
int niz[100005];
int tren[100005];
int dp[10005];
int dpp[10005];
int add(int a, int b){
return (a+b)%MOD;
}
int mul(int a, int b){
return ((ll)a*b)%MOD;
}
int main(){
ios_base::sync_with_stdio(false);
cout.precision(10);
cout<<fixed;
cin >> n;
for(int i=1; i<=n; i++){
cin >> niz[i];
tren[i] = max(niz[i], tren[i-1]);
}
for(int i=1; i<=n; i++){
dpp[i] = 1;
}
int res = 0;
for(int i=n; i>=1; i--){
for(int j=1; j<=n; j++){
dp[j] = add(mul(j, dpp[j]), dpp[j+1]);
}
res = add(res, mul(niz[i]-1, dpp[tren[i-1]]));
for(int j=1; j<=n; j++){
dpp[j] = dp[j];
}
}
cout << res+1 << "\n";
return 0;
}
# | 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... |