Submission #2436

#TimeUsernameProblemLanguageResultExecution timeMemory
2436rkdrjs0327지우개 (GA4_eraser)C++98
100 / 100
23 ms4792 KiB
#include<stdio.h> #include<algorithm> #define T 1000000007 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]; } d[c].sum%=T; } for(i=1; i<=c; i++) s[i]=(s[i-1]+d[i].sum)%T; for(i=1; i<=c; i++) temp[i]=(d[i].sum*s[i-1])%T; for(i=1; i<=c; i++) s[i]=(s[i-1]+temp[i])%T; for(i=1; i<=c; i++) temp[i]=(d[i].sum*s[i-1])%T; for(i=1; i<=c; i++) s[i]=(s[i-1]+temp[i])%T; 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...