# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
9274 | kcm1700 | Uniting (kriii2_U) | C++14 | 16 ms | 1476 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <algorithm>
#include <numeric>
using namespace std;
int n;
int dat[100003];
const int mod = 1000000007;
int main(){
scanf("%d",&n);
for(int i = 0; i < n; i++) scanf("%d",&dat[i]);
sort(dat, dat+n);
long long sum = accumulate(dat, dat+n, 0ll);
long long ans1 = 0;
long long ans2 = 1;
for(int i = 0; i < n; i++) {
sum -= dat[i];
ans1 += dat[i] * sum;
if (i >= 1) {
ans2 *= (i+1);
ans2 %= mod;
ans2 *= (i);
ans2 %= mod;
}
}
printf("%lld\n%lld\n", ans1,ans2);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |