fork(5) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. int32_t main() {
  6. ios_base::sync_with_stdio(false);
  7. cin.tie(nullptr), cout.tie(nullptr);
  8.  
  9. int n;
  10. cin >> n;
  11. vector<int> a(n);
  12. for(int i = 0; i < n; ++i) {
  13. cin >> a[i];
  14. }
  15. int mn = *min_element(a.begin(), a.end());
  16. int sum = accumulate(a.begin(), a.end(), 0);
  17. int res = sum;
  18. for(int i = 0; i < n; ++i) {
  19. for(int d = 1; d <= a[i]; ++d) {
  20. if (a[i] % d != 0) continue;
  21. int cur = sum - mn - a[i];
  22. cur += mn * d + a[i] / d;
  23. res = min(res, cur);
  24. }
  25. }
  26. cout << res << endl;
  27.  
  28. return 0;
  29. }
  30.  
Runtime error #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Standard output is empty