結果

問題 No.1463 Hungry Kanten
ユーザー kimiyukikimiyuki
提出日時 2021-04-02 21:52:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 448 ms / 2,000 ms
コード長 877 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 86,844 KB
実行使用メモリ 165,348 KB
最終ジャッジ日時 2023-08-25 14:56:48
合計ジャッジ時間 6,267 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 162 ms
79,828 KB
testcase_01 AC 162 ms
79,848 KB
testcase_02 AC 183 ms
84,060 KB
testcase_03 AC 412 ms
130,624 KB
testcase_04 AC 172 ms
83,344 KB
testcase_05 AC 448 ms
165,348 KB
testcase_06 AC 161 ms
79,920 KB
testcase_07 AC 163 ms
80,064 KB
testcase_08 AC 164 ms
79,980 KB
testcase_09 AC 163 ms
79,884 KB
testcase_10 AC 166 ms
81,048 KB
testcase_11 AC 166 ms
81,256 KB
testcase_12 AC 175 ms
83,368 KB
testcase_13 AC 167 ms
81,080 KB
testcase_14 AC 177 ms
83,412 KB
testcase_15 AC 177 ms
83,432 KB
testcase_16 AC 185 ms
84,408 KB
testcase_17 AC 202 ms
90,768 KB
testcase_18 AC 204 ms
84,172 KB
testcase_19 AC 297 ms
116,060 KB
testcase_20 AC 371 ms
133,040 KB
testcase_21 AC 168 ms
81,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
from typing import *

def solve(n: int, k: int, a: List[int]) -> int:
    constructed = []
    for x in range(2 ** n):
        s = 0
        p = 1
        popcount = 0
        for i in range(n):
            if x & (1 << i):
                s += a[i]
                p *= a[i]
                popcount += 1
        if k <= popcount:
            constructed.append(s)
            constructed.append(p)
    return len(set(constructed))


# generated by oj-template v4.7.2 (https://github.com/online-judge-tools/template-generator)
def main():
    import sys
    tokens = iter(sys.stdin.read().split())
    N = int(next(tokens))
    K = int(next(tokens))
    A = [None for _ in range(N)]
    for i in range(N):
        A[i] = int(next(tokens))
    assert next(tokens, None) is None
    a = solve(N, K, A)
    print(a)


if __name__ == '__main__':
    main()
0