Submission #7105

#TimeUsernameProblemLanguageResultExecution timeMemory
7105baneling100지우개 (GA4_eraser)C++98
100 / 100
16 ms3432 KiB
#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 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...