結果

問題 No.1463 Hungry Kanten
ユーザー nephrologistnephrologist
提出日時 2021-04-02 21:30:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 512 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 135,848 KB
最終ジャッジ日時 2023-08-25 14:47:17
合計ジャッジ時間 3,328 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
71,148 KB
testcase_01 AC 59 ms
71,444 KB
testcase_02 AC 73 ms
77,212 KB
testcase_03 AC 186 ms
79,296 KB
testcase_04 AC 62 ms
75,820 KB
testcase_05 AC 261 ms
135,848 KB
testcase_06 AC 69 ms
71,340 KB
testcase_07 AC 58 ms
71,152 KB
testcase_08 AC 62 ms
71,204 KB
testcase_09 AC 59 ms
71,392 KB
testcase_10 AC 65 ms
76,748 KB
testcase_11 AC 70 ms
75,940 KB
testcase_12 AC 72 ms
76,820 KB
testcase_13 AC 67 ms
76,164 KB
testcase_14 AC 77 ms
76,640 KB
testcase_15 AC 73 ms
76,588 KB
testcase_16 AC 76 ms
77,676 KB
testcase_17 AC 94 ms
81,396 KB
testcase_18 AC 77 ms
77,672 KB
testcase_19 AC 154 ms
102,956 KB
testcase_20 AC 182 ms
110,224 KB
testcase_21 AC 64 ms
76,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.buffer.readline
n, k = map(int, input().split())
A = list(map(int, input().split()))

ans = set()
popcnt = [0] * ((1 << n) + 10)
for i in range(1 << n):
    popcnt[i] = popcnt[i // 2] + i % 2
    if popcnt[i] >= k:
        goukei = 0
        prod = 1
        for j in range(n):
            if (i >> j) & 1:
                goukei += A[j]
                prod *= A[j]
        ans.add(goukei)
        ans.add(prod)
        # print(goukei)
        # print(prod)

print(len(list(ans)))
0