結果

問題 No.1043 直列大学
ユーザー convexineq
提出日時 2020-05-01 21:50:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 928 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 84,864 KB
最終ジャッジ日時 2024-12-22 19:26:12
合計ジャッジ時間 3,629 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#n,m,s = [int(i) for i in readline().split()]
n,m = [int(i) for i in readline().split()]
v = [int(i) for i in readline().split()]
r = [int(i) for i in readline().split()]
a,b = [int(i) for i in readline().split()]

MOD = 1000000007

def f(dp,v):
    res = 0
    for i in v:
        res = min(res+i,M)
        for j in range(res,i-1,-1):
            dp[j] += dp[j-i]
            dp[j] %= MOD
M = 100000

dp = [0]*(M+1)
dp[0] = 1
f(dp,v)

dpr = [0]*M
dpr[0] = 1
f(dpr,r)

from itertools import accumulate
acc = list(accumulate(dp))

#print(dp[:20],dpr[:20],acc[:20])

ans = -1
for i,v in enumerate(dpr):
    L = a*i
    R = min(M,b*i)
    #if i < 20: print(i,v,L,R)
    if L <= R:
        if i==0:
            ans += v*(acc[R])
        else:
            ans += v*(acc[R]-acc[L-1])
        
print(ans%MOD)
    
    
    
    







0