Submission #7901

#TimeUsernameProblemLanguageResultExecution timeMemory
7901gs14004지우개 (GA4_eraser)C++98
100 / 100
24 ms2648 KiB
#include <cstdio> int n; long long a[100005]; long long sum[100005]; long long mod = 1e9+7; int main(){ int t; scanf("%d",&n); for (int i=0; i<n; i++) { scanf("%d",&t); a[t]++; } for (int i=1; i<=100000; i++) { a[i] *= i; a[i] %= mod; } for (int i=1; i<=100000; i++) { sum[i] = a[i] + sum[i-1]; sum[i] %= mod; } for (int i=1; i<=100000; i++) { sum[i] = a[i] * (sum[100000] - sum[i]); sum[i] %= mod; } for (int i=1; i<=100000; i++) { sum[i] += sum[i-1]; sum[i] %= mod; } long long res = 0; for (int i=1; i<=100000; i++) { res += a[i] * (sum[100000] - sum[i]); res %= mod; } if(res < 0) res += mod; printf("%lld",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...