Submission #5633

#TimeUsernameProblemLanguageResultExecution timeMemory
5633gs13073지우개 (GA4_eraser)C++98
100 / 100
20 ms4996 KiB
#include<stdio.h> #include<algorithm> using namespace std; int a[100100],b[100100]; long long dp[4][100100]; //dp[i][j] : (1~j)까지, i개씩 곱들의 합 int main() { int N,i; //freopen("input.txt","r",stdin); scanf("%d",&N); for(i=1;i<=N;i++)scanf("%d",&a[i]); sort(a+1,a+N+1); int j=0; for(i=1;i<=N;i++){ if(a[i]!=a[i-1])j++; b[j]+=a[i]; } int J=j; //for(i=1;i<=J;i++)printf("%d ",b[i]); //puts(""); for(j=1;j<=J;j++)dp[1][j]=dp[1][j-1]+b[j]; for(i=2;i<=3;i++){ for(j=1;j<=J;j++){ if(j<i)continue; int tmp=(dp[i-1][j-1]*b[j])%1000000007; dp[i][j]=dp[i][j-1]+tmp; dp[i][j]%=1000000007; } } /*for(i=1;i<=3;i++){ for(j=1;j<=J;j++)printf("%d ",dp[i][j]); puts(""); }*/ printf("%lld",dp[3][J]); 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...