#include <cstdio>
using namespace std;
const int divider = 1000000007;
int N;
long long int a[100001];
long long int b[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);
b[i] %= divider;
}
for (i=1; i<=max; ++i) {
for (j=i+1; j<=max; ++j) {
s = a[i] * a[j] * i * j * (b[max] - b[j]);
sum += s % divider;
sum %= divider;
}
}
printf("%d\n", sum);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2448 KB |
Output is correct |
2 |
Correct |
0 ms |
2448 KB |
Output is correct |
3 |
Correct |
0 ms |
2448 KB |
Output is correct |
4 |
Correct |
0 ms |
2448 KB |
Output is correct |
5 |
Correct |
0 ms |
2448 KB |
Output is correct |
6 |
Correct |
0 ms |
2448 KB |
Output is correct |
7 |
Correct |
0 ms |
2448 KB |
Output is correct |
8 |
Correct |
0 ms |
2448 KB |
Output is correct |
9 |
Correct |
0 ms |
2448 KB |
Output is correct |
10 |
Correct |
0 ms |
2448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2448 KB |
Output is correct |
2 |
Correct |
0 ms |
2448 KB |
Output is correct |
3 |
Correct |
0 ms |
2448 KB |
Output is correct |
4 |
Correct |
0 ms |
2448 KB |
Output is correct |
5 |
Correct |
0 ms |
2448 KB |
Output is correct |
6 |
Correct |
0 ms |
2448 KB |
Output is correct |
7 |
Correct |
0 ms |
2448 KB |
Output is correct |
8 |
Correct |
0 ms |
2448 KB |
Output is correct |
9 |
Correct |
0 ms |
2448 KB |
Output is correct |
10 |
Correct |
0 ms |
2448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2448 KB |
Output is correct |
2 |
Correct |
2 ms |
2448 KB |
Output is correct |
3 |
Correct |
3 ms |
2448 KB |
Output is correct |
4 |
Correct |
3 ms |
2448 KB |
Output is correct |
5 |
Correct |
3 ms |
2448 KB |
Output is correct |
6 |
Correct |
3 ms |
2448 KB |
Output is correct |
7 |
Correct |
3 ms |
2448 KB |
Output is correct |
8 |
Correct |
3 ms |
2448 KB |
Output is correct |
9 |
Correct |
3 ms |
2448 KB |
Output is correct |
10 |
Correct |
3 ms |
2448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
2448 KB |
Output is correct |
2 |
Correct |
3 ms |
2448 KB |
Output is correct |
3 |
Correct |
3 ms |
2448 KB |
Output is correct |
4 |
Correct |
3 ms |
2448 KB |
Output is correct |
5 |
Correct |
3 ms |
2448 KB |
Output is correct |
6 |
Correct |
2 ms |
2448 KB |
Output is correct |
7 |
Correct |
3 ms |
2448 KB |
Output is correct |
8 |
Correct |
3 ms |
2448 KB |
Output is correct |
9 |
Correct |
2 ms |
2448 KB |
Output is correct |
10 |
Correct |
3 ms |
2448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
0 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1000 ms |
0 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |