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<stdio.h>
long long int d[100001], f[100002];
int main()
{
int n, i, j, k, a, max=0;
long long int z, ans=0;
scanf("%d", &n);
for(i=1;i<=n;i++){
scanf("%d", &a);
d[a]+=a;
if(max<a) max = a;
}
for(i=max;i>=1;i--) f[i] = f[i+1]+d[i];
for(i=1;i<=max-2;i++){
if(d[i]==0) continue;
for(j=i+1;j<max;j++){
if(d[j]==0) continue;
z = (f[j+1]*d[j])%1000000007;
z = (z*d[i])%1000000007;
ans = (ans+z)%1000000007;
}
}
printf("%lld", ans);
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... |