Submission #2538

#TimeUsernameProblemLanguageResultExecution timeMemory
2538tncks0121지우개 (GA4_eraser)C++98
100 / 100
19 ms3228 KiB
#include <cstdio> using namespace std; const int divider = 1000000007; int N; long long int a[100001]; long long int b[100001]; long long int c[100001]; int main() { int i, j, max = -1; int sum = 0; long long int s; scanf("%d", &N); for (i=0; i<N; ++i) { int tmp; scanf("%d", &tmp); ++a[tmp]; if (max < tmp) { max = tmp; } } for (i=1; i<=max; ++i) { b[i] = b[i-1] + ((a[i] * i) % divider); b[i] %= divider; } for (j=1; j<=max; ++j) { c[j] = c[j-1] + ((a[j] * j) % divider) * (b[max] - b[j] + divider) % divider; c[j] %= divider; } for (i=1; i<=max; ++i) { s = ((a[i] * i) % divider) * (c[max] - c[i] + divider) % divider; sum += s % divider; sum %= divider; } printf("%d\n", sum); 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...