Submission #7105

# Submission time Handle Problem Language Result Execution time Memory
7105 2014-07-25T11:19:27 Z baneling100 지우개 (GA4_eraser) C++
100 / 100
16 ms 3432 KB
#include <stdio.h>
#define MOD 1000000007

long long N, M, A[100001], B[100001], C[100001], Ans;

void input(void)
{
    long long i, temp;

    scanf("%lld",&N);
    for(i=1 ; i<=N ; i++)
    {
        scanf("%lld",&temp);
        A[temp]++;
        if(M<temp)
            M=temp;
    }
}

void process(void)
{
    long long i, sum=0;

    for(i=M ; i>=2 ; i--)
    {
        sum+=i*A[i];
        sum%=MOD;
        B[i-1]=(i-1)*sum*A[i-1];
        B[i-1]%=MOD;
    }
    sum=0;
    for(i=M-1 ; i>=2 ; i--)
    {
        sum+=B[i];
        sum%=MOD;
        C[i-1]=(i-1)*sum*A[i-1];
        C[i-1]%=MOD;
    }
    for(i=1 ; i<=M-2 ; i++)
    {
        Ans+=C[i];
        Ans%=MOD;
    }
}

void output(void)
{
    printf("%lld",Ans);
}

int main(void)
{
    input();
    process();
    output();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3432 KB Output is correct
2 Correct 0 ms 3432 KB Output is correct
3 Correct 0 ms 3432 KB Output is correct
4 Correct 0 ms 3432 KB Output is correct
5 Correct 0 ms 3432 KB Output is correct
6 Correct 0 ms 3432 KB Output is correct
7 Correct 0 ms 3432 KB Output is correct
8 Correct 0 ms 3432 KB Output is correct
9 Correct 0 ms 3432 KB Output is correct
10 Correct 0 ms 3432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3432 KB Output is correct
2 Correct 0 ms 3432 KB Output is correct
3 Correct 0 ms 3432 KB Output is correct
4 Correct 0 ms 3432 KB Output is correct
5 Correct 0 ms 3432 KB Output is correct
6 Correct 0 ms 3432 KB Output is correct
7 Correct 0 ms 3432 KB Output is correct
8 Correct 0 ms 3432 KB Output is correct
9 Correct 0 ms 3432 KB Output is correct
10 Correct 0 ms 3432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3432 KB Output is correct
2 Correct 0 ms 3432 KB Output is correct
3 Correct 0 ms 3432 KB Output is correct
4 Correct 0 ms 3432 KB Output is correct
5 Correct 0 ms 3432 KB Output is correct
6 Correct 0 ms 3432 KB Output is correct
7 Correct 0 ms 3432 KB Output is correct
8 Correct 0 ms 3432 KB Output is correct
9 Correct 0 ms 3432 KB Output is correct
10 Correct 0 ms 3432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3432 KB Output is correct
2 Correct 0 ms 3432 KB Output is correct
3 Correct 0 ms 3432 KB Output is correct
4 Correct 0 ms 3432 KB Output is correct
5 Correct 0 ms 3432 KB Output is correct
6 Correct 0 ms 3432 KB Output is correct
7 Correct 0 ms 3432 KB Output is correct
8 Correct 0 ms 3432 KB Output is correct
9 Correct 0 ms 3432 KB Output is correct
10 Correct 0 ms 3432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3432 KB Output is correct
2 Correct 4 ms 3432 KB Output is correct
3 Correct 4 ms 3432 KB Output is correct
4 Correct 8 ms 3432 KB Output is correct
5 Correct 0 ms 3432 KB Output is correct
6 Correct 12 ms 3432 KB Output is correct
7 Correct 4 ms 3432 KB Output is correct
8 Correct 8 ms 3432 KB Output is correct
9 Correct 8 ms 3432 KB Output is correct
10 Correct 12 ms 3432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 3432 KB Output is correct
2 Correct 4 ms 3432 KB Output is correct
3 Correct 12 ms 3432 KB Output is correct
4 Correct 0 ms 3432 KB Output is correct
5 Correct 16 ms 3432 KB Output is correct
6 Correct 0 ms 3432 KB Output is correct
7 Correct 16 ms 3432 KB Output is correct
8 Correct 12 ms 3432 KB Output is correct
9 Correct 16 ms 3432 KB Output is correct
10 Correct 16 ms 3432 KB Output is correct