結果
| 問題 |
No.1043 直列大学
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2020-05-01 22:39:42 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,201 bytes |
| コンパイル時間 | 112 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 48,400 KB |
| 最終ジャッジ日時 | 2024-12-25 13:30:24 |
| 合計ジャッジ時間 | 56,719 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 TLE * 17 |
ソースコード
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)
titia