結果

問題 No.1043 直列大学
ユーザー m4c_physics99m4c_physics99
提出日時 2020-05-02 00:21:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 778 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 15,020 KB
最終ジャッジ日時 2023-08-26 17:48:34
合計ジャッジ時間 5,445 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
15,020 KB
testcase_01 AC 14 ms
7,792 KB
testcase_02 AC 15 ms
7,832 KB
testcase_03 AC 14 ms
7,788 KB
testcase_04 AC 14 ms
7,832 KB
testcase_05 AC 14 ms
7,900 KB
testcase_06 AC 14 ms
7,840 KB
testcase_07 AC 14 ms
7,856 KB
testcase_08 AC 16 ms
7,856 KB
testcase_09 AC 348 ms
8,556 KB
testcase_10 AC 964 ms
8,952 KB
testcase_11 TLE -
testcase_12 -- -
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