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>
int n,c;
long long dtemp[100001],s[100001],temp[100001];
struct data
{
long long sum,val;
}; data d[100001];
void input()
{
int i;
scanf("%d",&n);
for(i=1; i<=n; i++) scanf("%lld",&dtemp[i]);
}
void process()
{
int i;
std::sort(dtemp+1,dtemp+n+1);
for(i=1; i<=n; i++){
if(dtemp[i]==d[c].val) d[c].sum+=dtemp[i];
else{
d[++c].val=dtemp[i];
d[c].sum=dtemp[i];
}
}
for(i=1; i<=c; i++) s[i]=s[i-1]+d[i].sum;
for(i=1; i<=c; i++) temp[i]=d[i].sum*s[i-1];
for(i=1; i<=c; i++) s[i]=s[i-1]+temp[i];
for(i=1; i<=c; i++) temp[i]=d[i].sum*s[i-1];
for(i=1; i<=c; i++) s[i]=s[i-1]+temp[i];
printf("%lld\n",s[c]);
}
int main()
{
input();
process();
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... |