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 <cstdio>
#include <algorithm>
using namespace std;
int dp[100001], val[100001], sum[100001];
const int mod = 1000000007;
int main() {
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",val+i);
for(int i=0;i<=n;i++) {
sum[i] = 1;
}
sort(val+1,val+1+n);
for(int p=0;p<3;p++) {
int pivot = 0;
for(int i=1;i<=n;i++) {
while(pivot<i && val[pivot]<val[i]) pivot++;
pivot--;
dp[i] = (int)((long long)sum[pivot]*val[i]%mod);
}
sum[0] = 0;
for(int i=1;i<=n;i++)
sum[i] = (sum[i-1]+dp[i])%mod;
}
printf("%d",sum[n]);
}
# | 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... |