fork download
  1. c = [416,585,464]
  2.  
  3. A0 = [100,50,200]
  4. A1 = [100,100,200]
  5. A2 = [100,150,100]
  6. A3 = [100,200,0]
  7. A4 = [100,250,0]
  8.  
  9. for b in [300,300,300,300,300], [350,400,350,300,350]:
  10.  
  11. from itertools import *
  12. print max(sum(compress(c, selectors))
  13. for selectors in product(*([[0, 1]] * 3))
  14. if all(sum(compress(num, selectors)) <= limit
  15. for num, limit in zip((A0, A1, A2, A3, A4), b)))
Success #stdin #stdout 0s 9024KB
stdin
Standard input is empty
stdout
1049
1465