結果

問題 No.1043 直列大学
ユーザー titiatitia
提出日時 2020-05-01 22:40:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 940 ms / 2,000 ms
コード長 1,201 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 186,108 KB
最終ジャッジ日時 2023-08-24 05:51:20
合計ジャッジ時間 14,806 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
85,012 KB
testcase_01 AC 111 ms
85,012 KB
testcase_02 AC 118 ms
85,008 KB
testcase_03 AC 114 ms
84,996 KB
testcase_04 AC 115 ms
85,064 KB
testcase_05 AC 113 ms
85,124 KB
testcase_06 AC 114 ms
85,132 KB
testcase_07 AC 113 ms
84,836 KB
testcase_08 AC 115 ms
85,000 KB
testcase_09 AC 168 ms
86,308 KB
testcase_10 AC 176 ms
87,008 KB
testcase_11 AC 190 ms
86,992 KB
testcase_12 AC 940 ms
186,108 KB
testcase_13 AC 694 ms
148,608 KB
testcase_14 AC 739 ms
159,924 KB
testcase_15 AC 860 ms
164,468 KB
testcase_16 AC 725 ms
155,008 KB
testcase_17 AC 465 ms
128,976 KB
testcase_18 AC 415 ms
121,076 KB
testcase_19 AC 695 ms
146,868 KB
testcase_20 AC 433 ms
125,296 KB
testcase_21 AC 622 ms
145,048 KB
testcase_22 AC 647 ms
144,952 KB
testcase_23 AC 879 ms
176,664 KB
testcase_24 AC 495 ms
124,724 KB
testcase_25 AC 689 ms
143,300 KB
testcase_26 AC 740 ms
148,636 KB
testcase_27 AC 341 ms
126,756 KB
testcase_28 AC 470 ms
145,640 KB
testcase_29 AC 144 ms
84,464 KB
testcase_30 AC 620 ms
175,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from collections import Counter
from itertools import accumulate

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=1000000007

C=Counter()
C[0]=1
for v in V:
    NC=Counter()
    for c in C:
        NC[c]=(NC[c]+C[c])%mod
        NC[c+v]=(NC[c+v]+C[c])%mod
    C=NC

C2=Counter()
C2[0]=1
for r in R:
    NC2=Counter()
    for c2 in C2:
        NC2[c2]=(NC2[c2]+C2[c2])%mod
        NC2[c2+r]=(NC2[c2+r]+C2[c2])%mod
    C2=NC2

del(C[0])
del(C2[0])

COUNT0=[0]*(10**5+1)
COUNT1=[0]*(10**5+1)

for c in C:
    COUNT0[c]=C[c]
for c2 in C2:
    COUNT1[c2]=C2[c2]

S1=list(accumulate(COUNT1))

ANS=0
r=0
for v in range(1,10**5+1):
    while r*B<v and r<=10**5:
        r+=1

    #print(v,r,ANS)
    if 0<=r-1<=10**5:
        ANS+=COUNT0[v]*(S1[-1]-S1[r-1])
    elif r==10**5+1:
        ANS+=COUNT0[v]*(S1[-1]-S1[10**5])
#print(ANS)

r=0
for v in range(1,10**5+1):
    while r*A<=v and r>=0:
        r+=1
    #print(v,r)
    if r<=10**5:
        ANS-=COUNT0[v]*(S1[-1]-S1[r-1])
    elif r==10**5+1:
        ANS-=COUNT0[v]*(S1[-1]-S1[10**5])
        
    
    
print(ANS%mod)
        

    
0