fork(2) download
  1. /*
  2. ZCO 2014 Smart Phone
  3. Yash Mathur
  4. */
  5.  
  6. #include <iostream>
  7. #include <algorithm>
  8.  
  9. using namespace std;
  10.  
  11. int main() {
  12.  
  13. int n;
  14. cin>>n;
  15. long long a[n], max=0, test;
  16. for(int i=0;i<n;++i){
  17. cin>>a[i];
  18. }
  19.  
  20. sort(a, a+n);
  21.  
  22. for(int i=0;i<n;++i){
  23. test = a[i]*(n-i);
  24. if(test>max)
  25. max=test;
  26. }
  27.  
  28. cout<<max;
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 3420KB
stdin
4
30
20
53
14
stdout
60