結果

問題 No.1043 直列大学
ユーザー roarisroaris
提出日時 2020-05-01 22:03:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,003 bytes
コンパイル時間 636 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 242,860 KB
最終ジャッジ日時 2023-08-26 13:36:21
合計ジャッジ時間 13,199 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
87,760 KB
testcase_01 AC 109 ms
86,112 KB
testcase_02 AC 134 ms
93,216 KB
testcase_03 AC 107 ms
86,212 KB
testcase_04 AC 107 ms
86,328 KB
testcase_05 AC 109 ms
86,176 KB
testcase_06 AC 109 ms
86,212 KB
testcase_07 AC 117 ms
89,532 KB
testcase_08 AC 115 ms
89,480 KB
testcase_09 AC 327 ms
163,812 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 472 ms
214,924 KB
testcase_14 AC 493 ms
223,348 KB
testcase_15 AC 540 ms
236,100 KB
testcase_16 AC 477 ms
220,472 KB
testcase_17 AC 381 ms
183,440 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 434 ms
202,336 KB
testcase_22 AC 484 ms
207,464 KB
testcase_23 WA -
testcase_24 AC 414 ms
193,528 KB
testcase_25 AC 470 ms
213,792 KB
testcase_26 AC 498 ms
223,264 KB
testcase_27 AC 304 ms
151,248 KB
testcase_28 AC 465 ms
212,280 KB
testcase_29 AC 225 ms
124,772 KB
testcase_30 AC 372 ms
180,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

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
dp1 = [[0]*(10**5+1) for _ in range(N+1)]
dp2 = [[0]*(10**5+1) for _ in range(M+1)]
dp1[0][0] = 1
dp2[0][0] = 1

for i in range(N):
    for j in range(10**5+1):
        dp1[i+1][j] += dp1[i][j]
        dp1[i+1][j] %= MOD
        
        if j+V[i]<=10**5:
            dp1[i+1][j+V[i]] += dp1[i][j]
            dp1[i+1][j+V[i]] %= MOD

acc = [0]

for i in range(10**5+1):
    acc.append((acc[-1]+dp1[N][i])%MOD)

for i in range(M):
    for j in range(10**5+1):
        dp2[i+1][j] += dp2[i][j]
        dp2[i+1][j] %= MOD
        
        if j+R[i]<=10**5:
            dp2[i+1][j+R[i]] += dp2[i][j]
            dp2[i+1][j+R[i]] %= MOD
    
ans = 0

for i in range(1, 10**5+1):
    if i*A<=10**5 and i*B<=10**5:
        ans += dp2[M][i]*(acc[i*B+1]-acc[i*A])
        ans %= MOD

print(ans)
0