結果
問題 |
No.1488 Max Score of the Tree
|
ユーザー |
|
提出日時 | 2025-09-07 03:01:08 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 957 bytes |
コンパイル時間 | 431 ms |
コンパイル使用メモリ | 82,340 KB |
実行使用メモリ | 67,528 KB |
最終ジャッジ日時 | 2025-09-07 03:01:12 |
合計ジャッジ時間 | 4,199 ms |
ジャッジサーバーID (参考情報) |
judge / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 29 |
ソースコード
## https://yukicoder.me/problems/no/1443 def main(): N = int(input()) A = list(map(int, input().split())) maxa = max(A) k = 0 while (1 << k) <= maxa: k += 1 dp = [0] * (1 << k) a_set = {0} answer = [0] * N for i in range(N): a = A[i] new_dp = [0] * (1 << k) new_a_set = set() for x in a_set: b = x & a new_a_set.add(b) c = x + a if c < (1 << k): new_a_set.add(c) else: new_dp[c % (1 << k)] += 1 for x in range(1 << k): if dp[x] > 0: b = x & a new_a_set.add(b) c = (x + a) % (1 << k) new_dp[c] += dp[x] a_set = new_a_set dp = new_dp answer[i] = sum(dp) + len(a_set) for i in range(N): print(answer[i]) if __name__ == "__main__": main()