Submission #2357

# Submission time Handle Problem Language Result Execution time Memory
2357 2013-07-21T03:59:02 Z sebin 지우개 (GA4_eraser) C++
0 / 100
42 ms 4088 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
using namespace std;

int in[100001];
long long d[100001];

long long mod(long long n){ return n%1000000007; }

int main()
{
    vector <long long> k;
    int n,a,i,maxa,mina;
    long long sum1=0,sum2=0;
    cin >> n;
    if(n<3){
        cout <<"0"<<endl;
        return 0;
    }
    maxa=0;
    mina=100001;
    for(i=1;i<=n;i++){
        cin >> a;
        in[a]++;
        if(maxa<a) maxa=a;
        if(mina>a) mina=a;
    }
    for(i=mina;i<=maxa;i++){
        if(in[i]>0){
            k.push_back(i*in[i]);
        }
    }
    d[2]=mod(mod(k[0]*k[1])*k[2]);
    sum1+=k[0]+k[1]+k[2];
    sum2+=mod(mod(k[0]*k[0])+mod(k[1]*k[1])+mod(k[2]*k[2]));
    for(i=3;i<k.size();i++){
        d[i]=mod(d[i-1]+(i+1)*(mod(sum1*sum1-sum2))/2);
        sum1=mod(sum1+k[i]);
        sum2=mod(sum2+k[i]*k[i]);
    }
    printf("%lld\n",d[k.size()-1]);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 4088 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 3320 KB Output isn't correct
2 Halted 0 ms 0 KB -