Submission #2435

#TimeUsernameProblemLanguageResultExecution timeMemory
2435rkdrjs0327지우개 (GA4_eraser)C++98
0 / 100
18 ms4792 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...