Submission #2539

# Submission time Handle Problem Language Result Execution time Memory
2539 2013-07-23T07:13:16 Z kipa00 지우개 (GA4_eraser) C++
100 / 100
16 ms 3228 KB
#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, 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) {
        long long int tmp = b[max] - b[i];
        if (tmp < 0) {
            tmp += divider;
        }
        c[i] = c[i-1] + (a[i] * i * tmp);
        c[i] %= divider;
    }
    for (i=1; i<=max; ++i) {
        long long int tmp = c[max] - c[i];
        if (tmp < 0) {
            tmp += divider;
        }
        s = a[i] * i * tmp;
        sum += s % divider;
        sum %= divider;
    }
    if (sum < 0) {
        sum += divider;
    }
    printf("%d\n", sum);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3228 KB Output is correct
2 Correct 0 ms 3228 KB Output is correct
3 Correct 0 ms 3228 KB Output is correct
4 Correct 0 ms 3228 KB Output is correct
5 Correct 0 ms 3228 KB Output is correct
6 Correct 0 ms 3228 KB Output is correct
7 Correct 0 ms 3228 KB Output is correct
8 Correct 0 ms 3228 KB Output is correct
9 Correct 0 ms 3228 KB Output is correct
10 Correct 0 ms 3228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3228 KB Output is correct
2 Correct 0 ms 3228 KB Output is correct
3 Correct 0 ms 3228 KB Output is correct
4 Correct 0 ms 3228 KB Output is correct
5 Correct 0 ms 3228 KB Output is correct
6 Correct 0 ms 3228 KB Output is correct
7 Correct 0 ms 3228 KB Output is correct
8 Correct 0 ms 3228 KB Output is correct
9 Correct 0 ms 3228 KB Output is correct
10 Correct 0 ms 3228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3228 KB Output is correct
2 Correct 0 ms 3228 KB Output is correct
3 Correct 0 ms 3228 KB Output is correct
4 Correct 0 ms 3228 KB Output is correct
5 Correct 0 ms 3228 KB Output is correct
6 Correct 0 ms 3228 KB Output is correct
7 Correct 0 ms 3228 KB Output is correct
8 Correct 0 ms 3228 KB Output is correct
9 Correct 0 ms 3228 KB Output is correct
10 Correct 0 ms 3228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3228 KB Output is correct
2 Correct 0 ms 3228 KB Output is correct
3 Correct 0 ms 3228 KB Output is correct
4 Correct 0 ms 3228 KB Output is correct
5 Correct 0 ms 3228 KB Output is correct
6 Correct 0 ms 3228 KB Output is correct
7 Correct 0 ms 3228 KB Output is correct
8 Correct 0 ms 3228 KB Output is correct
9 Correct 0 ms 3228 KB Output is correct
10 Correct 0 ms 3228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 3228 KB Output is correct
2 Correct 5 ms 3228 KB Output is correct
3 Correct 5 ms 3228 KB Output is correct
4 Correct 13 ms 3228 KB Output is correct
5 Correct 2 ms 3228 KB Output is correct
6 Correct 9 ms 3228 KB Output is correct
7 Correct 6 ms 3228 KB Output is correct
8 Correct 15 ms 3228 KB Output is correct
9 Correct 11 ms 3228 KB Output is correct
10 Correct 14 ms 3228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 3228 KB Output is correct
2 Correct 1 ms 3228 KB Output is correct
3 Correct 15 ms 3228 KB Output is correct
4 Correct 3 ms 3228 KB Output is correct
5 Correct 16 ms 3228 KB Output is correct
6 Correct 5 ms 3228 KB Output is correct
7 Correct 12 ms 3228 KB Output is correct
8 Correct 15 ms 3228 KB Output is correct
9 Correct 16 ms 3228 KB Output is correct
10 Correct 12 ms 3228 KB Output is correct