結果

問題 No.1043 直列大学
ユーザー ayaoni
提出日時 2020-12-18 20:16:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 471 ms / 2,000 ms
コード長 1,286 bytes
コンパイル時間 388 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 244,096 KB
最終ジャッジ日時 2024-12-22 20:13:36
合計ジャッジ時間 9,895 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import accumulate
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N,M = MI()
V,R = [0]+LI(),[0]+LI()
A,B = MI()
mod = 10**9+7

V_count = [[0]*100001 for _ in range(N+1)]
V_count[0][0] = 1
for i in range(1,N+1):
    v = V[i]
    for j in range(100001):
        V_count[i][j] = V_count[i-1][j]
        if j >= v:
            V_count[i][j] += V_count[i-1][j-v]
            V_count[i][j] %= mod

A_V_count = list(accumulate(V_count[-1]))

R_count = [[0]*100001 for _ in range(M+1)]
R_count[0][0] = 1
for i in range(1,M+1):
    r = R[i]
    for j in range(100001):
        R_count[i][j] = R_count[i-1][j]
        if j >= r:
            R_count[i][j] += R_count[i-1][j-r]
            R_count[i][j] %= mod

ans = 0
for i in range(1,100001):
    if A*i > 100000:
        break
    ans += R_count[-1][i]*(A_V_count[min(100000,B*i)]-A_V_count[A*i-1])
    ans %= mod

print(ans)
0