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>
#define MOD 1000000007
long long N, M, A[100001], B[100001], C[100001], Ans;
void input(void)
{
long long i, temp;
scanf("%lld",&N);
for(i=1 ; i<=N ; i++)
{
scanf("%lld",&temp);
A[temp]++;
if(M<temp)
M=temp;
}
}
void process(void)
{
long long i, sum=0;
for(i=M ; i>=2 ; i--)
{
sum+=i*A[i];
sum%=MOD;
B[i-1]=(i-1)*sum*A[i-1];
B[i-1]%=MOD;
}
sum=0;
for(i=M-1 ; i>=2 ; i--)
{
sum+=B[i];
sum%=MOD;
C[i-1]=(i-1)*sum*A[i-1];
C[i-1]%=MOD;
}
for(i=1 ; i<=M-2 ; i++)
{
Ans+=C[i];
Ans%=MOD;
}
}
void output(void)
{
printf("%lld",Ans);
}
int main(void)
{
input();
process();
output();
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... |