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;
const int T=1e9+7;
long long int Dp[100010][4];
long long int A[100010];
int X,N;
int main()
{
scanf("%d",&N);
int i,j;
for(i=1;i<=N;i++){
int x;scanf("%d",&x);
A[x]++;
X=max(X,x);
}
for(i=1;i<=X;i++){A[i]*=i;A[i]%=T;}
for(i=0;i<=X;i++)Dp[i][0]=1;
for(j=1;j<=3;j++){
for(i=1;i<=X;i++){
Dp[i][j]=Dp[i-1][j]+Dp[i-1][j-1]*A[i];
Dp[i][j]%=T;
}
}
printf("%d",Dp[X][3]);
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... |