Iamtui1010

S07E09

Nov 30th, 2021
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. #include<algorithm>
  4.  
  5. #define long long long
  6. #define nln '\n'
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.     long t;
  13.     cin >> t;
  14.     for (long i = 1; i <= t; ++i)
  15.     {
  16.         long n;
  17.         cin >> n;
  18.         vector<long> a;
  19.         for (long i = 1; i <= n; ++i)
  20.         {
  21.             long x;
  22.             cin >> x;
  23.             a.push_back(x);
  24.         }
  25.         sort(a.rbegin(), a.rend());
  26.         long loc = a.size()-1;
  27.         while (a[loc] == a[loc-1])
  28.             --loc;
  29.         cout << a[loc]*n + loc << nln;
  30.     }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment