fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. int cmpfunc (const void * a, const void * b)
  4. {
  5. return ( *(int*)a - *(int*)b );
  6. }
  7. int main()
  8. {
  9. long long N,cnt,i,j;
  10. scanf("%lld",&N);
  11. long long budgets[N];
  12. for(cnt=0; cnt<N; cnt++)
  13. scanf("%lld",&budgets[cnt]);
  14. qsort(budgets,N,sizeof(long long),cmpfunc);
  15. for(i=N-1,j=1; i>=0; i--,j++)
  16. budgets[i] *= j;
  17. qsort(budgets,N,sizeof(long long),cmpfunc);
  18. printf("%lld",budgets[N-1]);
  19. return 0;
  20. }
Success #stdin #stdout 0s 2172KB
stdin
4
30
20
53
14
stdout
60