Submission #5921

#TimeUsernameProblemLanguageResultExecution timeMemory
5921baneling100지우개 (GA4_eraser)C++98
22 / 100
16 ms3432 KiB
#include <stdio.h> #define MOD 1000000007 long long N, A[100001], M, B[100001], C[100001], Ans; void input(void) { int i; long long temp; scanf("%lld",&N); for(i=1 ; i<=N ; i++) { scanf("%lld",&temp); C[i]=temp; B[temp]=1; A[temp]+=temp; if(M<temp) M=temp; } for(i=M-1 ; i>=1 ; i--) A[i]+=A[i+1]; for(i=1 ; i<=M ; i++) if(B[i]) B[i]=i*A[i+1]; for(i=M-1 ; i>=1 ; i--) { B[i]+=B[i+1]; B[i]%=MOD; } } void process(void) { int i; for(i=1 ; i<=N ; i++) { Ans+=C[i]*B[C[i]+1]; 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...