Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #include<algorithm>
- #define long long long
- #define nln '\n'
- using namespace std;
- int main()
- {
- long t;
- cin >> t;
- for (long i = 1; i <= t; ++i)
- {
- long n;
- cin >> n;
- vector<long> a;
- for (long i = 1; i <= n; ++i)
- {
- long x;
- cin >> x;
- a.push_back(x);
- }
- sort(a.rbegin(), a.rend());
- long loc = a.size()-1;
- while (a[loc] == a[loc-1])
- --loc;
- cout << a[loc]*n + loc << nln;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment