fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef int li;
  5. typedef vector<li> vi;
  6. typedef vector<pair<li,li>> vii;
  7. typedef vector<vector<li>> vtd;
  8.  
  9. #define MP make_pair
  10. #define ff first
  11. #define ss second
  12. #define endl '\n'
  13. #define all(v) v.begin(), v.end()
  14. #define mod 1000000007
  15. #define pb push_back
  16.  
  17.  
  18. int main() {
  19.  
  20. ios_base::sync_with_stdio(false);
  21. cin.tie(NULL);
  22. cout.tie(0);
  23.  
  24. li n;
  25. cin>>n;
  26. li arr[n],ans=0;
  27. for(int i=0;i<n;i++)cin>>arr[i];
  28.  
  29. sort(arr,arr+n);
  30.  
  31. for(li i=0;i<n;i++){
  32. li pro=arr[i]*(n-i);
  33. ans=max(ans,pro);
  34. }
  35. cout<<ans;
  36. return 0;
  37. }
Success #stdin #stdout 0.01s 5496KB
stdin
Standard input is empty
stdout
2147479976