結果

問題 No.1043 直列大学
ユーザー m4c_physics99m4c_physics99
提出日時 2020-05-02 00:20:23
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 778 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 83,108 KB
最終ジャッジ日時 2023-08-26 17:46:20
合計ジャッジ時間 6,619 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
75,960 KB
testcase_01 AC 67 ms
71,240 KB
testcase_02 AC 71 ms
71,280 KB
testcase_03 AC 66 ms
71,516 KB
testcase_04 AC 66 ms
71,032 KB
testcase_05 AC 67 ms
71,212 KB
testcase_06 AC 66 ms
71,036 KB
testcase_07 AC 66 ms
71,348 KB
testcase_08 AC 66 ms
71,040 KB
testcase_09 AC 141 ms
77,300 KB
testcase_10 AC 233 ms
77,408 KB
testcase_11 AC 1,309 ms
78,264 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
v = list(map(int,input().split()))
r = list(map(int,input().split()))
a,b = map(int,input().split())
dpv = [0]*(sum(v)+1)
dpr = [0]*(sum(r)+1)
dpv[0] = 1
dpr[0] = 1
mod = 10**9+7
for i in range(n):
    for j in range(sum(v),-1,-1):
        if j+ v[i] <=sum(v):
            dpv[j+v[i]] += dpv[j]
            dpv[j+v[i]] %= mod
for i in range(m):
    for j in range(sum(r),-1,-1):
        if j+r[i] <= sum(r):
            dpr[j+r[i]]+= dpr[j]
            dpr[j+r[i]] %= mod
smv = [0]*(sum(v)+2)
for i in range(sum(v)+1):
    smv[i+1] = smv[i] + dpv[i]
ans = 0
for i in range(1,sum(r)+1):
    if dpr[i] == 0:continue
    vmin = a*i
    vmax = b*i
    
    ans += (smv[min(sum(v)+1,vmax+1)] - smv[min(sum(v)+1,vmin)])*dpr[i]
    ans %= mod
print(ans)
0