結果

問題 No.1443 Andd
ユーザー first_vilfirst_vil
提出日時 2021-01-23 15:56:51
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 763 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 81,044 KB
最終ジャッジ日時 2023-08-29 21:54:00
合計ジャッジ時間 9,737 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
75,388 KB
testcase_01 AC 77 ms
75,312 KB
testcase_02 AC 79 ms
75,372 KB
testcase_03 AC 381 ms
76,188 KB
testcase_04 AC 575 ms
76,080 KB
testcase_05 AC 425 ms
76,168 KB
testcase_06 AC 366 ms
76,296 KB
testcase_07 AC 553 ms
76,168 KB
testcase_08 AC 504 ms
76,536 KB
testcase_09 AC 116 ms
75,716 KB
testcase_10 AC 665 ms
76,180 KB
testcase_11 AC 601 ms
76,048 KB
testcase_12 AC 617 ms
76,516 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    kC=1<<14
    import sys
    input=sys.stdin.readline
    
    n=int(input())
    a=list(map(int,input().split()))
    now=[[False]*kC for _ in range(2)]
    dp=[[False]*kC for _ in range(2)]
    
    now[0][0]=True
    rkC=range(kC)
    ans=1
    output=[]
    for i in range(1,n+1):
        for j in rkC:
            dp[i&1][j]=False
            now[i&1][j]=False
            if now[~i&1][j]:
                dp[i&1][j&a[i-1]]=True
        for j in rkC:
            if now[~i&1][j]:
                now[i&1][(j+a[i-1])&(kC-1)]=True
            if dp[i&1][j]:
                ans+=1
                now[i&1][j]=True
        if now[~i&1][0] and dp[i&1][a[i-1]]:
            ans-=1
        output.append(str(ans))
    print('\n'.join(output))
main()
0