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 <iostream>
#include <stdio.h>
using namespace std;
long long a[100009],b[100009];
int main()
{
long long n,input,MaX,i,SizE=0;
long long Sum=0,Mid=0,MiD=0;
scanf("%lld",&n);
scanf("%lld",&input); MaX=input; a[input]++;
for(i=2;i<=n;i++)
{
scanf("%d",&input);
a[input]++;
if(MaX<input) MaX = input;
}
for(i=1;i<=MaX;i++)if(i*a[i])
{
SizE++;
b[SizE]=i*a[i];
}
for(i=1;i<=SizE;i++) Mid += b[i];
Sum += Mid*Mid*Mid;
for(i=1;i<=SizE;i++) Sum += 2*b[i]*b[i]*b[i];
Mid = 0;
for(i=1;i<=SizE;i++){Mid+=b[i]*b[i]; MiD+=b[i];}
Sum -= 3*Mid*MiD;
printf("%lld",Sum/6);
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... |