結果
問題 | No.1463 Hungry Kanten |
ユーザー |
|
提出日時 | 2021-04-02 21:52:12 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 320 ms / 2,000 ms |
コード長 | 877 bytes |
コンパイル時間 | 413 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 159,940 KB |
最終ジャッジ日時 | 2024-12-23 23:32:09 |
合計ジャッジ時間 | 3,586 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#!/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()