結果
| 問題 |
No.1463 Hungry Kanten
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-02 21:52:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 375 ms / 2,000 ms |
| コード長 | 877 bytes |
| コンパイル時間 | 180 ms |
| コンパイル使用メモリ | 82,416 KB |
| 実行使用メモリ | 156,688 KB |
| 最終ジャッジ日時 | 2025-06-20 01:32:50 |
| 合計ジャッジ時間 | 4,370 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 24 |
ソースコード
#!/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()