結果

問題 No.1043 直列大学
ユーザー 👑 KazunKazun
提出日時 2021-04-14 02:13:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 80,084 KB
最終ジャッジ日時 2023-08-24 12:55:55
合計ジャッジ時間 5,026 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,172 KB
testcase_01 AC 71 ms
71,284 KB
testcase_02 AC 71 ms
71,324 KB
testcase_03 AC 70 ms
71,512 KB
testcase_04 AC 70 ms
71,180 KB
testcase_05 AC 70 ms
71,332 KB
testcase_06 AC 70 ms
71,328 KB
testcase_07 AC 71 ms
71,464 KB
testcase_08 AC 70 ms
71,440 KB
testcase_09 AC 82 ms
76,288 KB
testcase_10 AC 83 ms
76,304 KB
testcase_11 AC 104 ms
76,932 KB
testcase_12 AC 156 ms
80,084 KB
testcase_13 AC 108 ms
77,200 KB
testcase_14 AC 110 ms
77,160 KB
testcase_15 AC 116 ms
77,412 KB
testcase_16 AC 110 ms
77,412 KB
testcase_17 AC 96 ms
76,940 KB
testcase_18 AC 98 ms
77,916 KB
testcase_19 AC 113 ms
77,164 KB
testcase_20 AC 99 ms
77,088 KB
testcase_21 AC 109 ms
77,104 KB
testcase_22 AC 115 ms
78,888 KB
testcase_23 AC 123 ms
77,408 KB
testcase_24 AC 107 ms
77,232 KB
testcase_25 AC 114 ms
77,284 KB
testcase_26 AC 110 ms
77,368 KB
testcase_27 AC 88 ms
76,752 KB
testcase_28 AC 94 ms
77,336 KB
testcase_29 AC 79 ms
76,104 KB
testcase_30 AC 104 ms
77,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Subsum_Count(L):
    L_sum=sum(L)
    X=[0]*(L_sum+1)
    X[0]=1

    for x in L:
        for a in range(L_sum,x-1,-1):
            X[a]+=X[a-x]
            X[a]%=Mod
    return X

N,M=map(int,input().split())
V=list(map(int,input().split()))
R=list(map(int,input().split()))
A,B=map(int,input().split())

Mod=10**9+7

V_sum=sum(V)
X=Subsum_Count(V)

R_sum=sum(R)
Y=Subsum_Count(R)

X_accum=[0]*len(X)
X_accum[0]=X[0]

for i in range(1,len(X)):
    X_accum[i]=X_accum[i-1]+X[i]
    X_accum[i]%=Mod

Ans=0
for r in range(1,R_sum+1):
    left =max(r*A,0)
    right=min(r*B,V_sum)

    if left>right:
        continue

    if left==0:
        Ans+=Y[r]*X_accum[right]
    else:
        Ans+=Y[r]*(X_accum[right]-X_accum[left-1])
    Ans%=Mod
print(Ans)
0