Advertisement
Derga

Untitled

Oct 24th, 2023 (edited)
841
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     int boards_count;
  9.     cin >> boards_count;
  10.     vector<uint64_t> boards_lengths(boards_count);
  11.     for (uint64_t& length : boards_lengths) {
  12.         cin >> length;
  13.     }
  14.  
  15.     sort(begin(boards_lengths), end(boards_lengths));
  16.     uint64_t result = 0;
  17.     for (uint64_t i = 0; i < boards_lengths.size(); ++i) {
  18.         result = max(result, boards_lengths[i] * (boards_lengths.size() - i));
  19.     }
  20.  
  21.     cout << result;
  22. }
  23. /*
  24. test1
  25. 5
  26. 1 2 3 4 5
  27.  
  28. 9
  29. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement