Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- n = int(input())
- nums = list(map(int, input().split()))
- summary = sum(nums)
- target_summ = summary // 2
- dp = [False for _ in range(target_summ + 1)]
- if target_summ and not summary % 2:
- dp[0] = True
- calc = dp[:]
- sums = list(range(1, target_summ + 1))
- for num in nums:
- for current_summ in sums:
- if current_summ >= num:
- calc[current_summ] = dp[current_summ] or dp[current_summ - num]
- dp = calc.copy()
- print(dp[-1])
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement