fork download
  1. import sys
  2.  
  3. def solve():
  4. input_data = sys.stdin.read().split()
  5.  
  6. if not input_data:
  7. return
  8.  
  9. data = [int(x) for x in input_data]
  10.  
  11. times = data[1:]
  12.  
  13. times.sort(reverse=True)
  14.  
  15. total_time = 0
  16. i = 0
  17. n = len(times)
  18.  
  19. while i < n:
  20. if i + 1 < n:
  21. total_time += times[i]
  22. i += 2
  23. else:
  24. total_time += times[i]
  25. i += 1
  26.  
  27. print(total_time)
  28.  
  29. if __name__ == "__main__":
  30. solve()
Success #stdin #stdout 0.12s 14164KB
stdin
4 
7 8 9 7
stdout
16