fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int workingWeeks(vector<int> proj) {
  5. long long total = 0;
  6. int mx = 0;
  7. for (int x : proj) {
  8. total += x;
  9. mx = max(mx, x);
  10. }
  11. long long rest = total - mx;
  12. if (mx > rest + 1) return 2 * rest + 1;
  13. return total;
  14. }
  15.  
  16. int main() {
  17. int n;
  18. cin >> n;
  19. vector<int> proj(n);
  20. for (int i = 0; i < n; i++) cin >> proj[i];
  21. cout << workingWeeks(proj);
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0.01s 5284KB
stdin
3
7 2 3
stdout
11