結果

問題 No.868 ハイパー部分和問題
ユーザー convexineqconvexineq
提出日時 2020-11-22 04:37:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 656 bytes
コンパイル時間 1,523 ms
コンパイル使用メモリ 86,692 KB
実行使用メモリ 78,980 KB
最終ジャッジ日時 2023-09-30 22:25:53
合計ジャッジ時間 38,089 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 85 ms
75,696 KB
testcase_02 AC 79 ms
75,732 KB
testcase_03 AC 80 ms
75,588 KB
testcase_04 AC 74 ms
71,308 KB
testcase_05 AC 74 ms
71,068 KB
testcase_06 AC 74 ms
70,980 KB
testcase_07 AC 76 ms
71,072 KB
testcase_08 AC 74 ms
70,800 KB
testcase_09 AC 74 ms
71,276 KB
testcase_10 AC 74 ms
70,976 KB
testcase_11 AC 74 ms
71,208 KB
testcase_12 AC 73 ms
71,068 KB
testcase_13 AC 74 ms
71,100 KB
testcase_14 AC 1,585 ms
77,608 KB
testcase_15 AC 1,572 ms
78,076 KB
testcase_16 AC 1,589 ms
77,844 KB
testcase_17 AC 1,580 ms
77,848 KB
testcase_18 AC 1,599 ms
77,640 KB
testcase_19 AC 1,122 ms
77,700 KB
testcase_20 AC 1,121 ms
77,508 KB
testcase_21 AC 1,134 ms
77,704 KB
testcase_22 AC 1,123 ms
77,492 KB
testcase_23 AC 1,162 ms
78,080 KB
testcase_24 AC 1,129 ms
77,728 KB
testcase_25 AC 1,127 ms
77,584 KB
testcase_26 AC 1,129 ms
78,612 KB
testcase_27 AC 1,131 ms
78,284 KB
testcase_28 AC 1,130 ms
78,488 KB
testcase_29 AC 860 ms
77,784 KB
testcase_30 AC 858 ms
78,236 KB
testcase_31 AC 848 ms
77,844 KB
testcase_32 AC 1,575 ms
77,660 KB
testcase_33 AC 1,577 ms
77,556 KB
testcase_34 AC 2,490 ms
78,312 KB
testcase_35 AC 2,460 ms
78,980 KB
testcase_36 AC 1,740 ms
77,732 KB
testcase_37 AC 1,736 ms
77,604 KB
testcase_38 AC 73 ms
71,284 KB
testcase_39 AC 73 ms
71,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n,k = map(int,readline().split())
*a, = map(int,readline().split())

def mul(c,m,dp): #multiply (1+x^c) up to x^m
    for i in range(m,c-1,-1):
        dp[i] += dp[i-c]
        dp[i] %= MOD
 
def div(c,m,dp): #divide by (1+x^c) up to x^m
    for i in range(m-c+1):
        dp[i+c] -= dp[i]
        dp[i+c] %= MOD

MOD = 10**9+7
dp = [0]*(k+1)
dp[0] = 1
for i in a:
    mul(i,k,dp)

q = int(readline())
for _ in range(q):
    x,v = map(int,readline().split())
    if a[x-1]: div(a[x-1],k,dp)
    if v: mul(v,k,dp)
    a[x-1] = v
    print(1 if dp[-1] else 0)
0