제출 #2179

#제출 시각아이디문제언어결과실행 시간메모리
2179jwvg0425지우개 (GA4_eraser)C++98
46 / 100
1000 ms2840 KiB
#include<stdio.h> #include<stdlib.h> #include<algorithm> #include<vector> using namespace std; #define MOD 1000000007 int n,r[100005]; long long int a[100005]; long long int v,s[100005]; int main() { int i,j,k; scanf("%d",&n); for(i=0;i<n;i++)scanf("%lld",&a[i]); sort(&a[0],&a[n]); s[0]=a[0]; r[0]=1; for(i=1;i<n;i++)s[i]=s[i-1]+a[i]; for(i=0;i<n;i++) { for(j=r[i];;j++) { if(a[j]!=a[i]) { r[i]=r[i+1]=j; break; } } } for(i=0;i<n;i++) { for(j=r[i];j<n-1;j++) { k=r[j]; if(k<n) { v=(v+(s[n-1]-s[k-1])*(long long int)a[i]*(long long int)a[j])%MOD; } } } printf("%lld",v); }
#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...