Submission #6445464
Source Code Expand
import sys sys.setrecursionlimit(4100000) import logging logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) def resolve(): N = [int(x) for x in sys.stdin.readline().split()][0] p_list = [int(x) for x in sys.stdin.readline().split()] logger.debug('{} {}'.format(N, p_list)) def res(i): if (i == N): return set([0]) else: ret_sets = res(i + 1) return set([s + p_list[i] for s in ret_sets]) | ret_sets print(len(res(0))) if __name__ == "__main__": resolve() # AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す # python -m unittest template/template.py で実行できる # pypy3 -m unittest template/template.py で実行できる import sys from io import StringIO import unittest class TestClass(unittest.TestCase): def assertIO(self, input, output): stdout, stdin = sys.stdout, sys.stdin sys.stdout, sys.stdin = StringIO(), StringIO(input) resolve() sys.stdout.seek(0) out = sys.stdout.read()[:-1] sys.stdout, sys.stdin = stdout, stdin self.assertEqual(out, output) def test_Sample_Input_1(self): input = """3 2 3 5""" output = """7""" self.assertIO(input, output) def test_Sample_Input_2(self): input = """10 1 1 1 1 1 1 1 1 1 1""" output = """11""" self.assertIO(input, output) def test_Sample_Input_3(self): input = """1 1""" output = """2""" self.assertIO(input, output)
Submission Info
Submission Time | |
---|---|
Task | A - コンテスト |
User | Kazhir |
Language | Python (3.4.3) |
Score | 2 |
Code Size | 1631 Byte |
Status | AC |
Exec Time | 110 ms |
Memory | 6380 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 2 / 2 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 00, 01, 02, 90, 91 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00 | AC | 110 ms | 6380 KB |
01 | AC | 52 ms | 5584 KB |
02 | AC | 82 ms | 5652 KB |
90 | AC | 44 ms | 5652 KB |
91 | AC | 44 ms | 5616 KB |