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>
#include<algorithm>
#define M 1000000007
using namespace std;
long long int a[100005];
long long int s[100005];
int n, m;
int b[100005];
int main()
{
long long int i, j, k;
scanf("%d",&n);
for(i=0; i<n; i++)
{
scanf("%lld",&j);
b[j]++;
}
for(i=1; i<=100000;i++)
{
if(b[i]>0)
{
a[++m]=(i*b[i])%M;
}
}
for(i=1;i<=m;i++)
s[i]=(s[i-1]+a[i])%M;
k=0;
for(i=1; i<=m; i++)
{
j=(s[i-1]*(s[m]-s[i]))%M;
k=(k+ j * a[i])%M;
}
printf("%lld\n",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... |