Submission #1637

#TimeUsernameProblemLanguageResultExecution timeMemory
1637ainta지우개 (GA4_eraser)C++98
100 / 100
25 ms1276 KiB
#include<stdio.h> #include<algorithm> using namespace std; int w[100001],n,i; long long c,s,g,res,Mod=1000000007; int main() { scanf("%d",&n); for(i=0;i<n;i++)scanf("%d",&w[i]); sort(w,w+n); for(i=n-1;i>=0;i--){ if(i!=n-1 && w[i]!=w[i+1]) { g=(g+s*c*w[i+1])%Mod; s=(s+c*w[i+1])%Mod; c=0; } c++; res=(res+g*w[i])%Mod; } printf("%lld\n",res); }
#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...