#include<stdio.h>
#include<stdlib.h>
#define MOD 1000000007
int n;
int a[100000];
long long int v,s[100000];
int compare(const void* a,const void* b)
{
return *((int*)a)-*((int*)b);
}
int main()
{
int i,j,k;
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%lld",&a[i]);
qsort(a,n,sizeof(int),compare);
s[0]=a[0];
for(i=1;i<n;i++)s[i]=s[i-1]+a[i];
for(i=0;i<n;i++)
{
for(j=i+1;j<n-1;j++)
{
if(a[i]==a[j])continue;
k=j+1;
while(a[k]==a[j])k++;
if(k<n)
{
v+=(s[n-1]-s[k-1])*(long long int)a[i]*(long long int)a[j]%MOD;
}
}
}
printf("%lld",v);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2056 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2056 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
2056 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
2056 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
11 ms |
2056 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
2056 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |