結果

問題 No.1043 直列大学
ユーザー ayaoniayaoni
提出日時 2020-12-18 20:16:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 483 ms / 2,000 ms
コード長 1,286 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 87,324 KB
実行使用メモリ 245,228 KB
最終ジャッジ日時 2023-08-24 12:54:32
合計ジャッジ時間 10,835 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
88,872 KB
testcase_01 AC 90 ms
85,432 KB
testcase_02 AC 118 ms
94,076 KB
testcase_03 AC 91 ms
85,284 KB
testcase_04 AC 91 ms
85,496 KB
testcase_05 AC 96 ms
87,128 KB
testcase_06 AC 96 ms
87,004 KB
testcase_07 AC 104 ms
88,532 KB
testcase_08 AC 106 ms
90,100 KB
testcase_09 AC 293 ms
164,436 KB
testcase_10 AC 333 ms
180,444 KB
testcase_11 AC 483 ms
226,816 KB
testcase_12 AC 474 ms
245,228 KB
testcase_13 AC 393 ms
213,588 KB
testcase_14 AC 407 ms
221,400 KB
testcase_15 AC 442 ms
234,736 KB
testcase_16 AC 408 ms
218,592 KB
testcase_17 AC 321 ms
181,800 KB
testcase_18 AC 338 ms
186,808 KB
testcase_19 AC 392 ms
212,604 KB
testcase_20 AC 317 ms
181,176 KB
testcase_21 AC 366 ms
202,364 KB
testcase_22 AC 381 ms
208,020 KB
testcase_23 AC 454 ms
240,944 KB
testcase_24 AC 347 ms
192,080 KB
testcase_25 AC 392 ms
212,740 KB
testcase_26 AC 413 ms
221,896 KB
testcase_27 AC 253 ms
151,572 KB
testcase_28 AC 395 ms
212,832 KB
testcase_29 AC 193 ms
125,116 KB
testcase_30 AC 319 ms
180,652 KB
権限があれば一括ダウンロードができます

ソースコード

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