結果

問題 No.1043 直列大学
ユーザー hedwig100hedwig100
提出日時 2020-05-01 21:48:57
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 185 ms / 2,000 ms
コード長 1,072 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 79,416 KB
最終ジャッジ日時 2023-08-24 05:41:21
合計ジャッジ時間 5,844 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
79,280 KB
testcase_01 AC 86 ms
79,228 KB
testcase_02 AC 93 ms
79,216 KB
testcase_03 AC 85 ms
79,316 KB
testcase_04 AC 85 ms
78,884 KB
testcase_05 AC 88 ms
79,152 KB
testcase_06 AC 88 ms
79,264 KB
testcase_07 AC 86 ms
78,924 KB
testcase_08 AC 87 ms
79,272 KB
testcase_09 AC 136 ms
79,404 KB
testcase_10 AC 148 ms
79,188 KB
testcase_11 AC 173 ms
79,160 KB
testcase_12 AC 181 ms
79,240 KB
testcase_13 AC 161 ms
79,196 KB
testcase_14 AC 169 ms
79,176 KB
testcase_15 AC 176 ms
79,020 KB
testcase_16 AC 169 ms
79,024 KB
testcase_17 AC 148 ms
79,148 KB
testcase_18 AC 148 ms
79,220 KB
testcase_19 AC 165 ms
79,188 KB
testcase_20 AC 150 ms
79,352 KB
testcase_21 AC 158 ms
79,136 KB
testcase_22 AC 165 ms
79,196 KB
testcase_23 AC 185 ms
79,416 KB
testcase_24 AC 156 ms
79,132 KB
testcase_25 AC 166 ms
78,968 KB
testcase_26 AC 173 ms
79,244 KB
testcase_27 AC 136 ms
79,284 KB
testcase_28 AC 171 ms
79,000 KB
testcase_29 AC 116 ms
78,972 KB
testcase_30 AC 143 ms
79,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
sys.setrecursionlimit(100000000)
from  bisect import bisect_left,bisect_right

def main():
    n,m = map(int,input().split())
    Volt = list(map(int,input().split()))
    Regist = list(map(int,input().split()))
    a,b = map(int,input().split())
    
    MAX = 100000
    dp1 = [1] + [0] * MAX
    for v in Volt:
        for j in range(MAX,0,-1):
            dp1[j] = dp1[j]
            if j - v >= 0:
                dp1[j] += dp1[j - v]
            dp1[j] %= MOD
    
    for i in range(1,MAX + 1):
        dp1[i] += dp1[i - 1]
        dp1[i] %= MOD
    
    dp2 = [1] + [0] * MAX
    for r in Regist:
        for j in range(MAX,0,-1):
            dp2[j] = dp2[j]
            if j - r >= 0:
                dp2[j] += dp2[j - r]
            dp2[j] %= MOD

    ans = 0
    for r in range(1,MAX + 1):
        if b*r <= MAX:
            ans += (dp1[b*r] - dp1[a*r - 1])*dp2[r]
        elif a*r - 1 <= MAX:
            ans += (dp1[-1] - dp1[a*r - 1])*dp2[r]
        ans %= MOD
    print(ans)

if __name__ == '__main__':
    main()
0