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