#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4792 KB |
Output is correct |
2 |
Correct |
0 ms |
4792 KB |
Output is correct |
3 |
Correct |
0 ms |
4792 KB |
Output is correct |
4 |
Correct |
0 ms |
4792 KB |
Output is correct |
5 |
Correct |
0 ms |
4792 KB |
Output is correct |
6 |
Correct |
0 ms |
4792 KB |
Output is correct |
7 |
Correct |
0 ms |
4792 KB |
Output is correct |
8 |
Correct |
0 ms |
4792 KB |
Output is correct |
9 |
Correct |
0 ms |
4792 KB |
Output is correct |
10 |
Correct |
0 ms |
4792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4792 KB |
Output is correct |
2 |
Correct |
0 ms |
4792 KB |
Output is correct |
3 |
Correct |
0 ms |
4792 KB |
Output is correct |
4 |
Correct |
0 ms |
4792 KB |
Output is correct |
5 |
Correct |
0 ms |
4792 KB |
Output is correct |
6 |
Correct |
0 ms |
4792 KB |
Output is correct |
7 |
Correct |
0 ms |
4792 KB |
Output is correct |
8 |
Correct |
0 ms |
4792 KB |
Output is correct |
9 |
Correct |
0 ms |
4792 KB |
Output is correct |
10 |
Correct |
0 ms |
4792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4792 KB |
Output is correct |
2 |
Correct |
0 ms |
4792 KB |
Output is correct |
3 |
Correct |
0 ms |
4792 KB |
Output is correct |
4 |
Correct |
0 ms |
4792 KB |
Output is correct |
5 |
Correct |
0 ms |
4792 KB |
Output is correct |
6 |
Correct |
0 ms |
4792 KB |
Output is correct |
7 |
Correct |
0 ms |
4792 KB |
Output is correct |
8 |
Correct |
0 ms |
4792 KB |
Output is correct |
9 |
Correct |
0 ms |
4792 KB |
Output is correct |
10 |
Correct |
0 ms |
4792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
4792 KB |
Output is correct |
2 |
Correct |
0 ms |
4792 KB |
Output is correct |
3 |
Correct |
0 ms |
4792 KB |
Output is correct |
4 |
Correct |
0 ms |
4792 KB |
Output is correct |
5 |
Correct |
0 ms |
4792 KB |
Output is correct |
6 |
Correct |
0 ms |
4792 KB |
Output is correct |
7 |
Correct |
0 ms |
4792 KB |
Output is correct |
8 |
Correct |
0 ms |
4792 KB |
Output is correct |
9 |
Correct |
0 ms |
4792 KB |
Output is correct |
10 |
Correct |
0 ms |
4792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
4792 KB |
Output is correct |
2 |
Correct |
4 ms |
4792 KB |
Output is correct |
3 |
Correct |
4 ms |
4792 KB |
Output is correct |
4 |
Correct |
13 ms |
4792 KB |
Output is correct |
5 |
Correct |
4 ms |
4792 KB |
Output is correct |
6 |
Correct |
11 ms |
4792 KB |
Output is correct |
7 |
Correct |
6 ms |
4792 KB |
Output is correct |
8 |
Correct |
19 ms |
4792 KB |
Output is correct |
9 |
Correct |
11 ms |
4792 KB |
Output is correct |
10 |
Correct |
16 ms |
4792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
4792 KB |
Output is correct |
2 |
Correct |
2 ms |
4792 KB |
Output is correct |
3 |
Correct |
16 ms |
4792 KB |
Output is correct |
4 |
Correct |
4 ms |
4792 KB |
Output is correct |
5 |
Correct |
17 ms |
4792 KB |
Output is correct |
6 |
Correct |
6 ms |
4792 KB |
Output is correct |
7 |
Correct |
15 ms |
4792 KB |
Output is correct |
8 |
Correct |
13 ms |
4792 KB |
Output is correct |
9 |
Correct |
17 ms |
4792 KB |
Output is correct |
10 |
Correct |
16 ms |
4792 KB |
Output is correct |