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>
using namespace std;
int w[100001],n,i;
long long c,s,g,res,Mod=1000000007;
int main()
{
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&w[i]);
sort(w,w+n);
for(i=n-1;i>=0;i--){
if(i!=n-1 && w[i]!=w[i+1])
{
g=(g+s*c*w[i+1])%Mod;
s=(s+c*w[i+1])%Mod;
c=0;
}
c++;
res=(res+g*w[i])%Mod;
}
printf("%lld\n",res);
}
# | 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... |