제출 #4127

#제출 시각아이디문제언어결과실행 시간메모리
4127pichulia지우개 (GA4_eraser)C++98
100 / 100
16 ms3040 KiB
#include<stdio.h> #include<algorithm> #define M 1000000007 using namespace std; long long int a[100005]; long long int s[100005]; int n, m; int b[100005]; int main() { long long int i, j, k; scanf("%d",&n); for(i=0; i<n; i++) { scanf("%lld",&j); b[j]++; } for(i=1; i<=100000;i++) { if(b[i]>0) { a[++m]=(i*b[i])%M; } } for(i=1;i<=m;i++) s[i]=(s[i-1]+a[i])%M; k=0; for(i=1; i<=m; i++) { j=(s[i-1]*(s[m]-s[i]))%M; k=(k+ j * a[i])%M; } printf("%lld\n",k); }
#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...