-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfindingMax.cpp
More file actions
43 lines (38 loc) · 795 Bytes
/
findingMax.cpp
File metadata and controls
43 lines (38 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @file findingMax.cpp
* @author long (you@domain.com)
* @brief find max answer
*
* @version 0.1
* @date 2023-03-18
*
* @copyright Copyright (c) 2023
*
*/
#include <iostream>
#include <vector>
#include <algorithm>
using std::cout, std::cin, std::vector;
const long long MODULO = 1e9 + 7;
int main() {
int t;
cin >> t;
while(t--) {
int n;
long long ans;
vector<long long> vt;
cin >> n;
for(int i=0; i<n; i++) {
int tmp;
cin >> tmp;
vt.push_back(tmp);
}
sort(vt.begin(), vt.end());
for(int i=0; i < n; i++) {
ans += (vt[i] * i);
ans = ans % MODULO;
}
ans = ans % MODULO;
cout << ans << std::endl;
}
}